i965/iris: fix crash when calling GetPerfQueryDataINTEL
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 24 Mar 2020 14:54:32 +0000 (16:54 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 24 Mar 2020 22:54:12 +0000 (22:54 +0000)
On a query that was never begun.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4302>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4302>

src/mesa/main/performance_query.c

index 1eaf0bb1a769f21e53577ac4ffaccf30cd3bd82b..c5825a7da3a533548288efcd3ac8cc1b4aa668d7 100644 (file)
@@ -617,6 +617,15 @@ _mesa_GetPerfQueryDataINTEL(GLuint queryHandle, GLuint flags,
     */
    *bytesWritten = 0;
 
+   /* Not explicitly covered in the spec but a query that was never started
+    * cannot return any data.
+    */
+   if (!obj->Used) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glGetPerfQueryDataINTEL(query never began)");
+      return;
+   }
+
    /* Not explicitly covered in the spec but to be consistent with
     * EndPerfQuery which validates that an application only ends an
     * active query we also validate that an application doesn't try