From 76d1cc3c1ce943c6ff81dc8c62a1d1b30fabf02e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 3 Apr 2022 14:23:36 +0100 Subject: 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 Conflict:NA Reference:https://cgit.freedesktop.org/xorg/lib/libX11/commit/?id=76d1cc3c1ce943c6ff81dc8c62a1d1b30fabf02e --- src/xcb_disp.c | 6 ++++-- 1 file 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); -- cgit v1.2.1