[PATCH] ephyr: Fix crash on 24bpp host framebuffer
Daniel Martin
consume.noise at gmail.com
Thu Feb 14 22:53:15 PST 2013
On Thu, Dec 20, 2012 at 01:50:17PM +0100, Daniel Martin wrote:
> Use bytes_per_line and bits_per_pixel from the created XImage to fix
> https://bugzilla.redhat.com/show_bug.cgi?id=518960
> ---
>
> Just encountered this bug. It was reported in 2009 and updated in 2011
> for the last time. But, it didn't made it upstream.
>
> This is a slightly modified version of the last patch Daniel Stone
> wrote. The difference is, that it gets bits_per_pixel from the XImage
> too.
>
>
> hw/kdrive/ephyr/ephyr.c | 6 ++----
> hw/kdrive/ephyr/hostx.c | 6 +++++-
> hw/kdrive/ephyr/hostx.h | 3 ++-
> 3 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
> index 109c599..82fb744 100644
> --- a/hw/kdrive/ephyr/ephyr.c
> +++ b/hw/kdrive/ephyr/ephyr.c
> @@ -238,13 +238,11 @@ ephyrMapFramebuffer(KdScreenInfo * screen)
> KdComputePointerMatrix(&m, ephyrRandr, 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);
> + hostx_screen_init(screen, screen->width, screen->height, buffer_height,
> + &priv->bytes_per_line, &screen->fb.bitsPerPixel);
>
> if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All)) {
> scrpriv->shadow = FALSE;
> diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
> index 50e94fa..53382f1 100644
> --- a/hw/kdrive/ephyr/hostx.c
> +++ b/hw/kdrive/ephyr/hostx.c
> @@ -622,7 +622,8 @@ hostx_set_cmap_entry(unsigned char idx,
> */
> void *
> hostx_screen_init(EphyrScreenInfo screen,
> - int width, int height, int buffer_height)
> + int width, int height, int buffer_height,
> + int *bytes_per_line, int *bits_per_pixel)
> {
> int bitmap_pad;
> Bool shm_success = False;
> @@ -699,6 +700,9 @@ hostx_screen_init(EphyrScreenInfo screen,
> malloc(host_screen->ximg->bytes_per_line * buffer_height);
> }
>
> + *bytes_per_line = host_screen->ximg->bytes_per_line;
> + *bits_per_pixel = 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 31c4053..38b7b37 100644
> --- a/hw/kdrive/ephyr/hostx.h
> +++ b/hw/kdrive/ephyr/hostx.h
> @@ -193,7 +193,8 @@ hostx_set_cmap_entry(unsigned char idx,
> unsigned char r, unsigned char g, unsigned char b);
>
> void *hostx_screen_init(EphyrScreenInfo screen,
> - int width, int height, int buffer_height);
> + int width, int height, int buffer_height,
> + int *bytes_per_line, int *bits_per_pixel);
>
> void
>
> --
> 1.7.2.5
The same for this one: anyone would like to review/sign it off?
More information about the xorg-devel
mailing list