[Mesa-dev] [PATCH] egl: Check if API is supported when using eglBindAPI.

Daniel Stone daniel at fooishbar.org
Fri May 13 16:09:30 UTC 2016


Hi,

On 13 May 2016 at 17:03, Plamena Manolova <plamena.manolova at intel.com> wrote:
> @@ -444,6 +444,8 @@ _eglCreateAPIsString(_EGLDisplay *dpy)
>        strcat(dpy->ClientAPIsString, "OpenVG ");
>
>     assert(strlen(dpy->ClientAPIsString) < sizeof(dpy->ClientAPIsString));
> +
> +   _eglGlobal.ClientAPIsString = dpy->ClientAPIsString;

What happens when the display is destroyed and this is freed? Or when
different displays have different supported APIs?

> @@ -69,7 +70,26 @@ struct _egl_thread_info
>  static inline EGLBoolean
>  _eglIsApiValid(EGLenum api)
>  {
> -   return (api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API);
> +   char *api_string;
> +   switch (api) {
> +      case EGL_OPENGL_API:
> +         api_string = "OpenGL";
> +         break;
> +      case EGL_OPENGL_ES_API:
> +         api_string = "OpenGL_ES";
> +         break;
> +      case EGL_OPENVG_API:
> +         api_string = "OpenVG";
> +         break;
> +      default:
> +         return EGL_FALSE;
> +      break;
> +   }
> +
> +   if (strstr(api_string, _eglGlobal.ClientAPIsString))
> +      return EGL_TRUE;
> +   else
> +      return EGL_FALSE;

This is trivially broken: it returns TRUE if a display only supports
OpenGL ES, but you request to bind OpenGL.

Cheers,
Daniel


More information about the mesa-dev mailing list