diff options
author | Dave Airlie <[email protected]> | 2012-03-23 18:37:16 +0000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2012-03-24 13:05:19 +0000 |
commit | 2c778375a1356ffb8db1522bc3fc64c568c35cb1 (patch) | |
tree | 4da4c68ebdee4c22d028c28420d0a97d5d24cf83 /src/glx | |
parent | 0f3aa9f4bd7daab354deb9268307c5628b460f6b (diff) |
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 <[email protected]>
Diffstat (limited to 'src/glx')
-rw-r--r-- | 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 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 = |