summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2013-04-08 20:00:30 -0700
committerIan Romanick <ian.d.romanick@intel.com>2013-05-10 16:41:30 -0700
commite928a3059c6addba9014b375b8b3d93ea31c4984 (patch)
tree0c5e51781fc869d948dc47f8aa5d1944e4aa2947
parent93613693ad70a34d0644149ae700daa3e2929286 (diff)
egl/dri2: NULL check value returned by dri2_create_surface
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. NOTE: This is a candidate for the stable branches. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (cherry picked from commit f730c210b89ab8eb2dd5f346a68d06bd05386a37)
-rw-r--r--src/egl/drivers/dri2/platform_x11.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index e9ca2411552..ccb097f1241 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;
}