egl/x11: bail out if we cannot fetch the xcb connection
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 29 Jul 2015 16:19:02 +0000 (17:19 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 7 Aug 2015 18:13:35 +0000 (19:13 +0100)
The documentation of xcb_connection_has_error() does not mention
what will happen, if NULL is fed to the function.

Upon closer look (props to Matt), it seems that we'll crash as the
implementation dereferences conn.

This will also allow us to remove the dri2_dpy->conn checking with the
next commit.

v2: Reword commit message as per Matt's findings.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
src/egl/drivers/dri2/platform_x11.c

index fecd36b3e7ed3bcb249a0f679faf0ed7a8665294..7a28318c008b842fa3a767be59175413c4ceecda 100644 (file)
@@ -1222,7 +1222,7 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
       dri2_dpy->screen = DefaultScreen(dpy);
    }
 
-   if (xcb_connection_has_error(dri2_dpy->conn)) {
+   if (!dri2_dpy->conn || xcb_connection_has_error(dri2_dpy->conn)) {
       _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed");
       goto cleanup_dpy;
    }