fix a possible memory leak if a list is empty for XmbTextPropertyToTextList
This commit is contained in:
1 parent
ce41d34791
commit
d587dd65a4
1 file changed
+3
-2
@@ -924,8 +924,9 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
|
||||
return 0;
|
||||
if (name.encoding == XA_STRING) {
|
||||
strncpy(text, (char *)name.value, size - 1);
|
||||
} else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) {
|
||||
strncpy(text, *list, size - 1);
|
||||
} else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success) {
|
||||
if (n > 0 && *list)
|
||||
strncpy(text, *list, size - 1);
|
||||
XFreeStringList(list);
|
||||
}
|
||||
text[size - 1] = '\0';
|
||||
|
||||
Reference in new issue
Block a user