From fd29e4acdae3a667e5b2519aa87ad457decb50c6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 24 May 2013 08:06:04 -0600 Subject: [PATCH] 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 --- src/gallium/state_trackers/glx/xlib/glx_api.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) 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); + } } -- 2.30.2