egl: Check for NULL native_window in eglCreateWindowSurface
authorSinclair Yeh <sinclair.yeh@intel.com>
Tue, 3 Jun 2014 21:00:13 +0000 (14:00 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 4 Jun 2014 00:28:30 +0000 (17:28 -0700)
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

v2: Incorporated feedback from idr - moved the check to a higher level
function.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
src/egl/main/eglapi.c

index 784681417e18c708c2e2b029f3be205f1b936e3b..096c3d8f5d84ffcbc1d16e5ed50b3ebfc80b8977 100644 (file)
@@ -571,6 +571,10 @@ _eglCreateWindowSurfaceCommon(_EGLDisplay *disp, EGLConfig config,
    EGLSurface ret;
 
    _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
+
+   if (native_window == NULL)
+      RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
+
    surf = drv->API.CreateWindowSurface(drv, disp, conf, native_window,
                                        attrib_list);
    ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE;