From: Daniel Kurtz <[email protected]>

From the EGL_EXT_client_extensions spec [0]
[0] 
https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_client_extensions.txt
1. How should clients detect if this extension is supported?
   RESOLVED: If an EGL implementation supports this extension, then
   `eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS)` returns
   a well-formed extension string and generates no error.  Otherwise, it
   returns NULL and generates EGL_BAD_DISPLAY.

So, detect the case where EGL_EXT_client_extensions is not supported and
just return false indicating that the requested client extension is also
not supported.

This keeps piglit_is_extension_in_string() from crashing when it tries
to find a needle in a NULL haystack.

Signed-off-by: Daniel Kurtz <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
---
 tests/util/piglit-util-egl.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tests/util/piglit-util-egl.c b/tests/util/piglit-util-egl.c
index 1754602..106c735 100644
--- a/tests/util/piglit-util-egl.c
+++ b/tests/util/piglit-util-egl.c
@@ -137,6 +137,16 @@ piglit_is_egl_extension_supported(EGLDisplay egl_dpy, 
const char *name)
        const char *const egl_extension_list =
                eglQueryString(egl_dpy, EGL_EXTENSIONS);
 
+       /*
+        * If EGL does not support EGL_EXT_client_extensions, then
+        * eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS) returns NULL and
+        * generates EGL_BAD_DISPLAY.  In this case, just report that the
+        * requested (client) extension is not supported.
+        */
+       if (!egl_extension_list && egl_dpy == EGL_NO_DISPLAY &&
+                       piglit_check_egl_error(EGL_BAD_DISPLAY))
+               return false;
+
        return piglit_is_extension_in_string(egl_extension_list, name);
 }
 
-- 
2.1.0

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to