From 3b55ac542018b1fc7832870ac9a28ce6ac79fcb7 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 15 May 2022 16:38:17 +1000 Subject: [PATCH] [client] x11: check for null data from XGetWindowProperty This fixes a reported segfault when a window manager fails to provide valid EWMH values. Fixes #987 --- client/displayservers/X11/x11.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index 52173a4d..9a792a52 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -190,14 +190,14 @@ static void x11CheckEWMHSupport(void) if (XGetWindowProperty(x11.display, DefaultRootWindow(x11.display), x11atoms._NET_SUPPORTING_WM_CHECK, 0, ~0L, False, XA_WINDOW, - &type, &fmt, &num, &bytes, &data) != Success) + &type, &fmt, &num, &bytes, &data) != Success || !data) goto out; Window * windowFromRoot = (Window *)data; if (XGetWindowProperty(x11.display, *windowFromRoot, x11atoms._NET_SUPPORTING_WM_CHECK, 0, ~0L, False, XA_WINDOW, - &type, &fmt, &num, &bytes, &data) != Success) + &type, &fmt, &num, &bytes, &data) != Success || !data) goto out_root; Window * windowFromChild = (Window *)data; @@ -206,7 +206,7 @@ static void x11CheckEWMHSupport(void) if (XGetWindowProperty(x11.display, DefaultRootWindow(x11.display), x11atoms._NET_SUPPORTED, 0, ~0L, False, AnyPropertyType, - &type, &fmt, &num, &bytes, &data) != Success) + &type, &fmt, &num, &bytes, &data) != Success || !data) goto out_child; Atom * supported = (Atom *)data; @@ -214,7 +214,7 @@ static void x11CheckEWMHSupport(void) if (XGetWindowProperty(x11.display, *windowFromRoot, x11atoms._NET_WM_NAME, 0, ~0L, False, AnyPropertyType, - &type, &fmt, &num, &bytes, &data) != Success) + &type, &fmt, &num, &bytes, &data) != Success || !data) goto out_supported; char * wmName = (char *)data;