From 19c9a8e29667bc1e8fc2ff896f8b6d8a34ae48f7 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Tue, 15 Jan 2019 18:29:32 +0100 Subject: [PATCH] Harden against undefined X Atoms Fixes #589 --- src/x11/screen.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/x11/screen.c b/src/x11/screen.c index 7ef1300..a9ac74a 100644 --- a/src/x11/screen.c +++ b/src/x11/screen.c @@ -256,15 +256,19 @@ bool window_is_fullscreen(Window window) if (result == Success) { for(int i = 0; i < n_items; i++) { - char *atom = XGetAtomName(xctx.dpy, ((Atom*)prop_to_return)[i]); + Atom atom = ((Atom*) prop_to_return)[i]; + if (!atom) + continue; - if (atom) { - if(STR_EQ("_NET_WM_STATE_FULLSCREEN", atom)) - fs = true; - XFree(atom); - if(fs) - break; - } + char *s = XGetAtomName(xctx.dpy, atom); + if (!s) + continue; + + if (STR_EQ(s, "_NET_WM_STATE_FULLSCREEN")) + fs = true; + XFree(s); + if (fs) + break; } }