summaryrefslogtreecommitdiff
path: root/src/glx
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2010-09-08 14:51:18 -0400
committerKristian Høgsberg <krh@bitplanet.net>2010-09-08 18:54:48 -0400
commit659dab6be6bc82f8a0551c30f1133e0010f04ed8 (patch)
tree77b0f101fe9e6128fed9a449418b7ca47db542de /src/glx
parentfc1daab2a2846912d3da5eb69e1ce0afbf08ab04 (diff)
glx: Fix use after free problem
Diffstat (limited to 'src/glx')
-rw-r--r--src/glx/glxcurrent.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c
index 710985b02c..0d359f72b4 100644
--- a/src/glx/glxcurrent.c
+++ b/src/glx/glxcurrent.c
@@ -248,12 +248,6 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
oldGC->currentDrawable = None;
oldGC->currentReadable = None;
oldGC->thread_id = 0;
- if (oldGC->xid == None && oldGC != gc)
- /* We are switching away from a context that was
- * previously destroyed, so we need to free the memory
- * for the old handle.
- */
- oldGC->vtable->destroy(oldGC);
}
if (gc) {
@@ -267,6 +261,13 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
__glXSetCurrentContextNull();
}
+ if (oldGC != &dummyContext && oldGC->xid == None && oldGC != gc) {
+ /* We are switching away from a context that was
+ * previously destroyed, so we need to free the memory
+ * for the old handle. */
+ oldGC->vtable->destroy(oldGC);
+ }
+
if (ret) {
__glXGenerateError(dpy, gc, None, ret, X_GLXMakeContextCurrent);
return GL_FALSE;