aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2018-06-30 10:17:36 +0900
committerDominique Martinet <asmadeus@codewreck.org>2018-06-30 11:38:21 +0900
commitbcc2c64c1e1a4562699a94deb6f9d57e1e072ed8 (patch)
tree47823fbd8d44f5ced5e1a2e6af62fb13f77e1c64
parent4f7b1382d4ceb1ed308563809d485ea6c047f077 (diff)
x11 backend init: fix leak on failed XOpenDisplay
Found through static analysis
-rw-r--r--backend/x11/backend.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index d4793b9c..e35cbed7 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -245,13 +245,13 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
x11->xlib_conn = XOpenDisplay(x11_display);
if (!x11->xlib_conn) {
wlr_log(L_ERROR, "Failed to open X connection");
- return NULL;
+ goto error_x11;
}
x11->xcb_conn = XGetXCBConnection(x11->xlib_conn);
if (!x11->xcb_conn || xcb_connection_has_error(x11->xcb_conn)) {
wlr_log(L_ERROR, "Failed to open xcb connection");
- goto error_x11;
+ goto error_display;
}
XSetEventQueueOwner(x11->xlib_conn, XCBOwnsEventQueue);
@@ -262,7 +262,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
x11->event_source = wl_event_loop_add_fd(ev, fd, events, x11_event, x11);
if (!x11->event_source) {
wlr_log(L_ERROR, "Could not create event source");
- goto error_x11;
+ goto error_display;
}
x11->screen = xcb_setup_roots_iterator(xcb_get_setup(x11->xcb_conn)).data;
@@ -291,8 +291,9 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
error_event:
wl_event_source_remove(x11->event_source);
-error_x11:
+error_display:
XCloseDisplay(x11->xlib_conn);
+error_x11:
free(x11);
return NULL;
}