From 20798291ca32b17acd757e54ef479b2d6905c84e Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Wed, 6 Apr 2011 18:05:40 +0200 Subject: [PATCH] Check return value of XOpenDisplay(). 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 --- compositor/compositor-x11.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compositor/compositor-x11.c b/compositor/compositor-x11.c index ba593c14..acc08fad 100644 --- a/compositor/compositor-x11.c +++ b/compositor/compositor-x11.c @@ -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))