diff options
author | Adam Jackson <ajax@redhat.com> | 2011-06-27 15:13:54 -0400 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-09-08 11:06:32 +1000 |
commit | a0f60f4dc32e3dbd844a7348bf9a54394f1d280e (patch) | |
tree | 72ab741143c897dc47aa2052500901b2aac275d4 | |
parent | afdcc3b4b3b223dc1c6a18c2e756e71baf25d73d (diff) |
kdrive/ephyr: Fix crash on 24bpp host framebuffer
bytes_per_line in the XImage will (more or less) reflect the pixmap
format of the server. On 24bpp servers it will be approximately 3*width
(plus scanline padding); we were assuming depth 24 always meant 32bpp,
so the exposure painting in root window map would walk off the end of
the image and crash.
Signed-off-by: Adam Jackson <ajax@redhat.com>
-rw-r--r-- | hw/kdrive/ephyr/ephyr.c | 9 | ||||
-rw-r--r-- | hw/kdrive/ephyr/hostx.c | 4 | ||||
-rw-r--r-- | hw/kdrive/ephyr/hostx.h | 2 |
3 files changed, 10 insertions, 5 deletions
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index db21df6bb..c788c96bd 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -252,11 +252,14 @@ ephyrMapFramebuffer (KdScreenInfo *screen) KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height); KdSetPointerMatrix (&m); - priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2; - 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, &priv->bytes_per_line); + + /* laaaaaame */ + if (screen->fb.depth == 24) + if (priv->bytes_per_line < (screen->width * 4)) + screen->fb.bitsPerPixel = 24; 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 b85e325c3..eb4e474d7 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -639,7 +639,7 @@ hostx_set_cmap_entry(unsigned char idx, void* hostx_screen_init (EphyrScreenInfo screen, int width, int height, - int buffer_height) + int buffer_height, int *bytes_per_line) { int bitmap_pad; Bool shm_success = False; @@ -724,6 +724,8 @@ hostx_screen_init (EphyrScreenInfo screen, malloc (host_screen->ximg->bytes_per_line * buffer_height); } + *bytes_per_line = host_screen->ximg->bytes_per_line; + XResizeWindow (HostX.dpy, host_screen->win, width, height); XMapWindow(HostX.dpy, host_screen->win); diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index 69e3ceb7b..b0627da0b 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -203,7 +203,7 @@ hostx_set_cmap_entry(unsigned char idx, void* hostx_screen_init (EphyrScreenInfo screen, int width, int height, - int buffer_height); + int buffer_height, int *bytes_per_line); void hostx_paint_rect(EphyrScreenInfo screen, |