[PATCH] glx: Prevent NULL context deref in __glXGetDrawable()

Chris Wilson chris at chris-wilson.co.uk
Thu Jun 24 04:15:03 PDT 2010


During a SwapBuffers request, we may end up querying an unknown drawable
outside of an active context, and so need to report this error prior to
attempting to dereference the NULL context.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Kristian Høgsberg <krh at bitplanet.net>
---
 glx/glxcmds.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 9e5b213..8d13c15 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -491,6 +491,13 @@ __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client,
 	return pGlxDraw;
     }
 
+    /* No active context and an unknown drawable, bail. */
+    if (glxc == NULL) {
+	    client->errorValue = drawId;
+	    *error = BadMatch;
+	    return NULL;
+    }
+
     /* The drawId wasn't a GLX drawable.  Make sure it's a window and
      * create a GLXWindow for it.  Check that the drawable screen
      * matches the context screen and that the context fbconfig is
-- 
1.7.1



More information about the xorg-devel mailing list