From 76a43c5fba9ccb5e7f945a06ce711b381da0819b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 10 Mar 2011 08:50:52 -0700 Subject: [PATCH] glx: fix null pointer deref in __glXGenerateError() The gc var would be NULL if called from line 238. Instead, get the opcode from __glXSetupForCommand(dpy) as done in other places. And remove the unused gc parameter. Fixes a bug reported by "John Doe" on 3/9/2011. NOTE: This is a candidate for the 7.10 branch. --- src/glx/glxcurrent.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index 9a6499037b1..1f845ce65e1 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -189,7 +189,7 @@ glXGetCurrentDrawable(void) } static void -__glXGenerateError(Display * dpy, struct glx_context *gc, XID resource, +__glXGenerateError(Display * dpy, XID resource, BYTE errorCode, CARD16 minorCode) { xError error; @@ -198,7 +198,7 @@ __glXGenerateError(Display * dpy, struct glx_context *gc, XID resource, error.resourceID = resource; error.sequenceNumber = dpy->request; error.type = X_Error; - error.majorCode = gc->majorOpcode; + error.majorCode = __glXSetupForCommand(dpy); error.minorCode = minorCode; _XError(dpy, &error); } @@ -235,12 +235,12 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, } if (gc == NULL && (draw != None || read != None)) { - __glXGenerateError(dpy, gc, (draw != None) ? draw : read, + __glXGenerateError(dpy, (draw != None) ? draw : read, BadMatch, X_GLXMakeContextCurrent); return False; } if (gc != NULL && (draw == None || read == None)) { - __glXGenerateError(dpy, gc, None, BadMatch, X_GLXMakeContextCurrent); + __glXGenerateError(dpy, None, BadMatch, X_GLXMakeContextCurrent); return False; } @@ -284,7 +284,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, __glXUnlock(); if (ret) { - __glXGenerateError(dpy, gc, None, ret, X_GLXMakeContextCurrent); + __glXGenerateError(dpy, None, ret, X_GLXMakeContextCurrent); return GL_FALSE; } -- 2.30.2