Check return value of XOpenDisplay().
authorCyril Brulebois <kibi@debian.org>
Wed, 6 Apr 2011 16:05:40 +0000 (18:05 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 7 Apr 2011 13:07:33 +0000 (09:07 -0400)
Instead of calling XGetXCBConnection() blindly, check XOpenDisplay()'s
return value to avoid a possible segfault in the former. That happens if
$DISPLAY is set, but if that display isn't available.

Signed-off-by: Cyril Brulebois <kibi@debian.org>
compositor/compositor-x11.c

index ba593c1..acc08fa 100644 (file)
@@ -553,6 +553,10 @@ x11_compositor_create(struct wl_display *display, int width, int height)
        memset(c, 0, sizeof *c);
 
        c->dpy = XOpenDisplay(NULL);
+
+       if (c->dpy == NULL)
+               return NULL;
+
        c->conn = XGetXCBConnection(c->dpy);
 
        if (xcb_connection_has_error(c->conn))