glx: Don't allow glXMakeContextCurrent() with only one valid drawable
authorAdam Jackson <ajax@redhat.com>
Fri, 6 Jul 2018 18:59:21 +0000 (14:59 -0400)
committerAdam Jackson <ajax@redhat.com>
Mon, 9 Jul 2018 16:03:18 +0000 (12:03 -0400)
Drawable and readable need to either both be None or both be non-None.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/glx/glxcurrent.c

index fd04929b89f3a2bbac5d5d06b7e291cfbc516420..2b9c708c3ee6fc97fd11fa503bbdbbce54a21eb6 100644 (file)
@@ -194,6 +194,13 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
       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);