From: Ian Romanick <ian.d.roman...@intel.com> dri2_create_surface can fail for a variety of reasons, including bad input data. Dereferencing the NULL pointer and crashing is not okay.
Fixes issue identified by Klocwork analysis: Pointer 'surf' returned from call to function 'dri2_create_surface' at line 285 may be NULL and will be dereferenced at line 291. Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> --- src/egl/drivers/dri2/platform_x11.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index da61cfc..86eeafa 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -284,14 +284,15 @@ dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, surf = dri2_create_surface(drv, disp, EGL_WINDOW_BIT, conf, window, attrib_list); - - /* When we first create the DRI2 drawable, its swap interval on the server - * side is 1. - */ - surf->SwapInterval = 1; - - /* Override that with a driconf-set value. */ - drv->API.SwapInterval(drv, disp, surf, dri2_dpy->default_swap_interval); + if (surf != NULL) { + /* When we first create the DRI2 drawable, its swap interval on the + * server side is 1. + */ + surf->SwapInterval = 1; + + /* Override that with a driconf-set value. */ + drv->API.SwapInterval(drv, disp, surf, dri2_dpy->default_swap_interval); + } return surf; } -- 1.8.1.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev