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

Sinclair Yeh sinclair.yeh at intel.com
Fri May 30 16:58:56 PDT 2014


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.

This fix adds a check and sets EGL_BAD_NATIVE_WINDOW
---
 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)
+   {
+      _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");
-- 
1.9.1



More information about the mesa-dev mailing list