mirror of
https://git.suckless.org/dwm
synced 2024-12-27 03:16:32 +00:00
gettextprop: check result of XGetTextProperty (undefined behaviour for XFree)
This commit is contained in:
parent
a9b6a312a7
commit
99f78fa553
1 changed files with 1 additions and 2 deletions
3
dwm.c
3
dwm.c
|
@ -910,8 +910,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
|
||||||
if (!text || size == 0)
|
if (!text || size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
text[0] = '\0';
|
text[0] = '\0';
|
||||||
XGetTextProperty(dpy, w, &name, atom);
|
if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems)
|
||||||
if (!name.nitems)
|
|
||||||
return 0;
|
return 0;
|
||||||
if (name.encoding == XA_STRING)
|
if (name.encoding == XA_STRING)
|
||||||
strncpy(text, (char *)name.value, size - 1);
|
strncpy(text, (char *)name.value, size - 1);
|
||||||
|
|
Loading…
Reference in a new issue