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>
This commit is contained in:
Simon McVittie 2022-04-03 14:23:36 +01:00
parent 80b30d1251
commit 76d1cc3c1c

View file

@ -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);