File U_Don-t-try-to-destroy-NULL-condition-variables.patch of Package libX11.30862

From 76d1cc3c1ce943c6ff81dc8c62a1d1b30fabf02e Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@debian.org>
Date: Sun, 3 Apr 2022 14:23:36 +0100
Subject: [PATCH] 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>
---
 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);
-- 
2.35.3

openSUSE Build Service is sponsored by