glx: Generate GLXBadDrawable when drawable is zero
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 9 Aug 2013 01:17:24 +0000 (18:17 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 14 Aug 2013 00:53:33 +0000 (17:53 -0700)
Fixes piglit glx-query-drawable-GLXBadDrawable.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Cc: "9.2" <mesa-stable@lists.freedesktop.org>
src/glx/glx_pbuffer.c

index f11305a41df014114e9152fc35e7a7126d7e55ab..183fbaaa5004d03b1ea271edfa5ef0ca710bd782 100644 (file)
 #ifdef GLX_USE_APPLEGL
 #include <pthread.h>
 #include "apple_glx_drawable.h"
-#include "glx_error.h"
 #endif
 
+#include "glx_error.h"
+
 #define WARN_ONCE_GLX_1_3(a, b) {              \
                static int warned=1;            \
                if(warned) {                    \
@@ -279,7 +280,16 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
    unsigned int num_attributes;
    GLboolean use_glx_1_3;
 
-   if ((dpy == NULL) || (drawable == 0)) {
+   if (dpy == NULL)
+      return 0;
+
+   /* Page 38 (page 52 of the PDF) of glxencode1.3.pdf says:
+    *
+    *     "If drawable is not a valid GLX drawable, a GLXBadDrawable error is
+    *     generated."
+    */
+   if (drawable == 0) {
+      __glXSendError(dpy, GLXBadDrawable, 0, X_GLXGetDrawableAttributes, false);
       return 0;
    }