[PATCH] xephyr: Fix crash in initial MapWindow on 24bpp host servers

Adam Jackson ajax at redhat.com
Fri Jul 16 12:29:01 PDT 2010


Previous code assumed we were always 32bpp, so root window paint walked
off the end of the XImage and things went boom.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 hw/kdrive/ephyr/ephyr.c |    3 ++-
 hw/kdrive/ephyr/hostx.c |    7 ++++---
 hw/kdrive/ephyr/hostx.h |    3 ++-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 8096a24..8943de3 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -256,7 +256,8 @@ ephyrMapFramebuffer (KdScreenInfo *screen)
 
   buffer_height = ephyrBufferHeight(screen);
 
-  priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height);
+  priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height,
+				  &screen->fb.bitsPerPixel);
 
   if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All))
     {
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 2ebeca9..cb72587 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -636,9 +636,8 @@ hostx_set_cmap_entry(unsigned char idx,
  * by fakexa for storing offscreen pixmap data.
  */
 void*
-hostx_screen_init (EphyrScreenInfo screen,
-                   int width, int height,
-                   int buffer_height)
+hostx_screen_init (EphyrScreenInfo screen, int width, int height,
+                   int buffer_height, int *bpp)
 {
   int         bitmap_pad;
   Bool        shm_success = False;
@@ -724,6 +723,8 @@ hostx_screen_init (EphyrScreenInfo screen,
               malloc (host_screen->ximg->bytes_per_line * buffer_height);
     }
 
+  *bpp = host_screen->ximg->bits_per_pixel;
+
   XResizeWindow (HostX.dpy, host_screen->win, width, height);
 
   /* Ask the WM to keep our size static */
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index e65e0c9..4fa8003 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -195,7 +195,8 @@ hostx_set_cmap_entry(unsigned char idx,
 void*
 hostx_screen_init (EphyrScreenInfo screen,
                    int width, int height,
-                   int buffer_height);
+                   int buffer_height,
+		   int *bpp);
 
 void
 hostx_paint_rect(EphyrScreenInfo screen,
-- 
1.7.1.1



More information about the xorg-devel mailing list