summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2022-04-03 14:23:36 +0100
committerSimon McVittie <smcv@debian.org>2022-04-03 14:24:13 +0100
commit76d1cc3c1ce943c6ff81dc8c62a1d1b30fabf02e (patch)
treebb6019b416528ea8533877b97789733bedd778fa /src
parent80b30d12519ac54fc5b2b05500521d9c8269be9c (diff)
Don't try to destroy NULL condition variables
This avoids a segfault during error-unwinding if an invalid display name is passed to XOpenDisplay(). Fixes: 8a368d80 "Fix two memory leaks in _XFreeX11XCBStructure()" Resolves: #155 Signed-off-by: Simon McVittie <smcv@debian.org>
Diffstat (limited to 'src')
-rw-r--r--src/xcb_disp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/xcb_disp.c b/src/xcb_disp.c
index e9becee3..63e344af 100644
--- a/src/xcb_disp.c
+++ b/src/xcb_disp.c
@@ -102,8 +102,10 @@ void _XFreeX11XCBStructure(Display *dpy)
dpy->xcb->pending_requests = tmp->next;
free(tmp);
}
- xcondition_clear(dpy->xcb->event_notify);
- xcondition_clear(dpy->xcb->reply_notify);
+ if (dpy->xcb->event_notify)
+ xcondition_clear(dpy->xcb->event_notify);
+ if (dpy->xcb->reply_notify)
+ xcondition_clear(dpy->xcb->reply_notify);
xcondition_free(dpy->xcb->event_notify);
xcondition_free(dpy->xcb->reply_notify);
Xfree(dpy->xcb);