From: Dave Airlie Date: Fri, 23 Mar 2012 18:37:16 +0000 (+0000) Subject: glx/drisw: avoid segfaults when we fail to get visual X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2c778375a1356ffb8db1522bc3fc64c568c35cb1;p=mesa.git glx/drisw: avoid segfaults when we fail to get visual 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 --- diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 9cee25e932b..95d2dcc04b2 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 =