fix a possible memory leak if a list is empty for XmbTextPropertyToTextList

This commit is contained in:
Hiltjo Posthuma committed 2026-10-16 13:26:00 +02:00
1 parent ce41d34791
commit d587dd65a4
1 file changed
+2 -1
+2 -1
View File
@@ -924,7 +924,8 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
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);
} else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) { } else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success) {
if (n > 0 && *list)
strncpy(text, *list, size - 1); strncpy(text, *list, size - 1);
XFreeStringList(list); XFreeStringList(list);
} }