[Mesa-dev] [PATCH 1/2] st/xlib: Fix XImage bytes-per-pixel calculation

Richard Sandiford rsandifo at linux.vnet.ibm.com
Fri Jun 14 03:05:41 PDT 2013


Fixes a crash seen while running gnome on a 16-bit screen over vnc.

Signed-off-by: Richard Sandiford <rsandifo at linux.vnet.ibm.com>
---
 src/gallium/state_trackers/glx/xlib/xm_api.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index b758c8e..36ebb46 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -1407,9 +1407,8 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
          return;
       }
 
-      /* The pipe transfer has a pitch rounded up to the nearest 64 pixels.
-         We assume 32 bit pixels. */
-      ximage_stride = w * 4;
+      /* The pipe transfer has a pitch rounded up to the nearest 64 pixels.  */
+      ximage_stride = w * ((img->bits_per_pixel + 7) / 8);
 
       for (line = 0; line < h; line++)
          memcpy(&map[line * tex_xfer->stride],
-- 
1.7.11.7



More information about the mesa-dev mailing list