From: Brian Paul Date: Fri, 24 May 2013 14:06:04 +0000 (-0600) Subject: st/glx: add null ctx check in glXDestroyContext() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fd29e4acdae3a667e5b2519aa87ad457decb50c6;p=mesa.git st/glx: add null ctx check in glXDestroyContext() Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64934 NOTE: This is a candidate for the stable branches. Reviewed-by: Jose Fonseca --- diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index a66ebc8e8a4..c6dc134c5cf 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -1353,16 +1353,18 @@ glXQueryExtension( Display *dpy, int *errorBase, int *eventBase ) PUBLIC void glXDestroyContext( Display *dpy, GLXContext ctx ) { - GLXContext glxCtx = ctx; - (void) dpy; - MakeCurrent_PrevContext = 0; - MakeCurrent_PrevDrawable = 0; - MakeCurrent_PrevReadable = 0; - MakeCurrent_PrevDrawBuffer = 0; - MakeCurrent_PrevReadBuffer = 0; - XMesaDestroyContext( glxCtx->xmesaContext ); - XMesaGarbageCollect(); - free(glxCtx); + if (ctx) { + GLXContext glxCtx = ctx; + (void) dpy; + MakeCurrent_PrevContext = 0; + MakeCurrent_PrevDrawable = 0; + MakeCurrent_PrevReadable = 0; + MakeCurrent_PrevDrawBuffer = 0; + MakeCurrent_PrevReadBuffer = 0; + XMesaDestroyContext( glxCtx->xmesaContext ); + XMesaGarbageCollect(); + free(glxCtx); + } }