From d587dd65a4d55c810438336170301b67e69dcade Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Tue, 13 Oct 2026 14:37:57 +0200 Subject: fix a possible memory leak if a list is empty for XmbTextPropertyToTextList --- dwm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dwm.c b/dwm.c index 515e4e4..f26a943 100644 --- a/dwm.c +++ b/dwm.c @@ -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'; -- cgit v1.3.1