[Mesa-dev] [PATCH] glx/drisw: avoid segfaults when we fail to get visual
Jose Fonseca
jfonseca at vmware.com
Fri Mar 23 14:11:28 PDT 2012
Looks good to me.
Jose
----- Original Message -----
> From: Dave Airlie <airlied at redhat.com>
>
> piglit glx-tfp segfaults on llvmpipe when run vs a 16-bit radeon
> screen,
>
> it now fails instead of segfaulting, much prettier.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
> src/glx/drisw_glx.c | 11 +++++++++--
> 1 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
> index 9cee25e..95d2dcc 100644
> --- a/src/glx/drisw_glx.c
> +++ b/src/glx/drisw_glx.c
> @@ -91,6 +91,9 @@ XCreateDrawable(struct drisw_drawable * pdp,
> visMask = VisualIDMask;
> pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp,
> &num_visuals);
>
> + if (!pdp->visinfo || num_visuals == 0)
> + return False;
> +
> /* create XImage */
> pdp->ximage = XCreateImage(dpy,
> pdp->visinfo->visual,
> @@ -513,7 +516,7 @@ driswCreateDrawable(struct glx_screen *base, XID
> xDrawable,
> struct drisw_drawable *pdp;
> __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
> struct drisw_screen *psc = (struct drisw_screen *) base;
> -
> + Bool ret;
> const __DRIswrastExtension *swrast = psc->swrast;
>
> pdp = Xmalloc(sizeof(*pdp));
> @@ -525,7 +528,11 @@ driswCreateDrawable(struct glx_screen *base, XID
> xDrawable,
> pdp->base.drawable = drawable;
> pdp->base.psc = &psc->base;
>
> - XCreateDrawable(pdp, psc->base.dpy, xDrawable, modes->visualID);
> + ret = XCreateDrawable(pdp, psc->base.dpy, xDrawable,
> modes->visualID);
> + if (!ret) {
> + Xfree(pdp);
> + return NULL;
> + }
>
> /* Create a new drawable */
> pdp->driDrawable =
> --
> 1.7.7.6
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list