glx: Fix use-before-null-check in dri2InvalidateBuffers().
authorEric Anholt <eric@anholt.net>
Wed, 1 Jun 2011 20:39:39 +0000 (13:39 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 3 Jun 2011 23:03:34 +0000 (16:03 -0700)
The compiler used our dereference here to skip the NULL check below.
Fixes window resize in "jconsole -J-Dsun.java2d.opengl=True" under
OpenJDK 6.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=37766
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glx/dri2_glx.c

index b9f6f7fcf031ae448cc12c69600965ce5db1d0a7..69b47ae45e2d5716ce74be976d7f3d71363601c6 100644 (file)
@@ -675,9 +675,14 @@ dri2InvalidateBuffers(Display *dpy, XID drawable)
 {
    __GLXDRIdrawable *pdraw =
       dri2GetGlxDrawableFromXDrawableId(dpy, drawable);
-   struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
+   struct dri2_screen *psc;
    struct dri2_drawable *pdp = (struct dri2_drawable *) pdraw;
 
+   if (!pdraw)
+      return;
+
+   psc = (struct dri2_screen *) pdraw->psc;
+
 #if __DRI2_FLUSH_VERSION >= 3
    if (pdraw && psc->f && psc->f->base.version >= 3 && psc->f->invalidate)
        psc->f->invalidate(pdp->driDrawable);