[Mesa-dev] [PATCH] Check for NULL native_window into dri2_wl_create_surface

Ian Romanick idr at freedesktop.org
Fri May 30 17:09:41 PDT 2014


On 05/30/2014 04:58 PM, Sinclair Yeh wrote:
> We have customers using NULL as a way to test the robustness of
> the API.  Without this check, EGL will segfault trying to
> dereference dri2_surf->wl_win->private because wl_win is
> NULL.

It sounds like we need a piglit test for this... :)

Should this check actually go at a higher level?  It seems that other
window system back-ends could have the same problem.

> This fix adds a check and sets EGL_BAD_NATIVE_WINDOW

It looks like this same code exists in the 10.2 branch and the 10.1
branch.  This patch should be tagged with:

Cc: "10.1 10.2" <mesa-stable at lists.freedesktop.org>

> ---
>  src/egl/drivers/dri2/platform_wayland.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
> index 537d26e..66f51e9 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -130,6 +130,13 @@ dri2_wl_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
>  
>     (void) drv;
>  
> +   if (NULL == window)
> +   {

    if (window == NULL) {

> +      _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
> +      return NULL;
> +   }
> +
> +
>     dri2_surf = malloc(sizeof *dri2_surf);
>     if (!dri2_surf) {
>        _eglError(EGL_BAD_ALLOC, "dri2_create_surface");
> 



More information about the mesa-dev mailing list