diff options
| author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2026-10-13 14:37:57 +0200 |
|---|---|---|
| committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2026-10-16 13:26:00 +0200 |
| commit | d587dd65a4d55c810438336170301b67e69dcade (patch) | |
| tree | 58e8c443886035e7dbdf548a93f61a9a79e5279b | |
| parent | properly NUL terminate ltsymbol (diff) | |
| download | dwm-d587dd65a4d55c810438336170301b67e69dcade.tar.gz dwm-d587dd65a4d55c810438336170301b67e69dcade.zip | |
fix a possible memory leak if a list is empty for XmbTextPropertyToTextList
| -rw-r--r-- | dwm.c | 5 |
1 files changed, 3 insertions, 2 deletions
| @@ -924,8 +924,9 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) | |||
| 924 | return 0; | 924 | return 0; |
| 925 | if (name.encoding == XA_STRING) { | 925 | if (name.encoding == XA_STRING) { |
| 926 | strncpy(text, (char *)name.value, size - 1); | 926 | strncpy(text, (char *)name.value, size - 1); |
| 927 | } else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) { | 927 | } else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success) { |
| 928 | strncpy(text, *list, size - 1); | 928 | if (n > 0 && *list) |
| 929 | strncpy(text, *list, size - 1); | ||
| 929 | XFreeStringList(list); | 930 | XFreeStringList(list); |
| 930 | } | 931 | } |
| 931 | text[size - 1] = '\0'; | 932 | text[size - 1] = '\0'; |
