[Piglit] [PATCH 02/14] piglit-util-egl: check if EGL_EXT_client_extensions is supported

Vinson Lee vlee at freedesktop.org
Mon Apr 27 21:36:50 PDT 2015


On Mon, Apr 13, 2015 at 11:28 AM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Daniel Kurtz <djkurtz at chromium.org>
>
> 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 <djkurtz at chromium.org>
> Reviewed-by: Marek Olšák <marek.olsak at amd.com>
> ---
>  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
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


This patch introduced this Coverity defect.


** CID 1295430:  Null pointer dereferences  (FORWARD_NULL)
/tests/util/piglit-util-egl.c: 146 in piglit_is_egl_extension_supported()


________________________________________________________________________________________________________
*** CID 1295430:  Null pointer dereferences  (FORWARD_NULL)
/tests/util/piglit-util-egl.c: 146 in piglit_is_egl_extension_supported()
140             /*
141              * If EGL does not support EGL_EXT_client_extensions, then
142              * eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS)
returns NULL and
143              * generates EGL_BAD_DISPLAY.  In this case, just
report that the
144              * requested (client) extension is not supported.
145              */
>>>     CID 1295430:  Null pointer dereferences  (FORWARD_NULL)
>>>     Comparing "egl_extension_list" to null implies that "egl_extension_list" might be null.
146             if (!egl_extension_list && egl_dpy == EGL_NO_DISPLAY &&
147                             piglit_check_egl_error(EGL_BAD_DISPLAY))
148                     return false;
149
150             return piglit_is_extension_in_string(egl_extension_list, name);
151     }


More information about the Piglit mailing list