[Mesa-dev] [PATCH 11/11] glx: Added missing null check in GetDrawableAttribute()

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Thu Jun 19 05:24:28 PDT 2014


For GLX_BACK_BUFFER_AGE_EXT query added extra null check.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 src/glx/glx_pbuffer.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
index 8f48093..322f241 100644
--- a/src/glx/glx_pbuffer.c
+++ b/src/glx/glx_pbuffer.c
@@ -319,7 +319,6 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
    pdraw = GetGLXDRIDrawable(dpy, drawable);
 
    if (attribute == GLX_BACK_BUFFER_AGE_EXT) {
-      struct glx_screen *psc = pdraw->psc;
       struct glx_context *gc = __glXGetCurrentContext();
 
       /* The GLX_EXT_buffer_age spec says:
@@ -328,12 +327,16 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
        *   the calling thread's current context a GLXBadDrawable error is
        *   generated."
        */
-      if (gc == NULL || gc->currentDpy != dpy ||
-         (gc->currentDrawable != drawable && gc->currentReadable != drawable)) {
-         __glXSendError(dpy, GLXBadDrawable, drawable, X_GLXGetDrawableAttributes, false);
+      if (pdraw == NULL || gc == NULL || gc->currentDpy != dpy ||
+         (gc->currentDrawable != drawable &&
+         gc->currentReadable != drawable)) {
+         __glXSendError(dpy, GLXBadDrawable, drawable,
+                        X_GLXGetDrawableAttributes, false);
          return 0;
       }
 
+      struct glx_screen *psc = pdraw->psc;
+
       if (psc->driScreen->getBufferAge != NULL)
          *value = psc->driScreen->getBufferAge(pdraw);
 
-- 
1.8.1.2



More information about the mesa-dev mailing list