glx: Don't allow glXMakeContextCurrent() with only one valid drawable
[mesa.git] / src / glx / glxcurrent.c
index fd04929b89f3a2bbac5d5d06b7e291cfbc516420..2b9c708c3ee6fc97fd11fa503bbdbbce54a21eb6 100644 (file)
@@ -194,6 +194,13 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
       return True;
    }
 
       return True;
    }
 
+   /* can't have only one be 0 */
+   if (!!draw != !!read) {
+      __glXUnlock();
+      __glXSendError(dpy, BadMatch, None, X_GLXMakeContextCurrent, True);
+      return False;
+   }
+
    if (oldGC != &dummyContext) {
       if (--oldGC->thread_refcount == 0) {
         oldGC->vtable->unbind(oldGC, gc);
    if (oldGC != &dummyContext) {
       if (--oldGC->thread_refcount == 0) {
         oldGC->vtable->unbind(oldGC, gc);