From: Hiltjo Posthuma Date: Fri, 3 Nov 2017 15:36:32 +0000 (+0100) Subject: gettextprop: check result of XGetTextProperty (undefined behaviour for XFree) X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=99f78fa553f9ddb23fab73e47a408d66ca7f974c;p=dwm.git gettextprop: check result of XGetTextProperty (undefined behaviour for XFree) --- diff --git a/dwm.c b/dwm.c index b0d99c0..650d19f 100644 --- a/dwm.c +++ b/dwm.c @@ -910,8 +910,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) if (!text || size == 0) return 0; text[0] = '\0'; - XGetTextProperty(dpy, w, &name, atom); - if (!name.nitems) + if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems) return 0; if (name.encoding == XA_STRING) strncpy(text, (char *)name.value, size - 1);