commit bfb071698a2b5889497a9e6a082b6ba114dad0ef
parent 7c0334de3dd84a3c40ee5bdfb5a8e547445e25c9
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 27 Oct 2026 21:10:35 +0100
getline: add check for len > 0
This condition cannot happen here though.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dmenu.c b/dmenu.c
@@ -562,7 +562,7 @@ readstdin(void)
if (!(items = realloc(items, itemsiz * sizeof(*items))))
die("cannot realloc %zu bytes:", itemsiz * sizeof(*items));
}
- if (line[len - 1] == '\n')
+ if (len > 0 && line[len - 1] == '\n')
line[len - 1] = '\0';
if (!(items[i].text = strdup(line)))
die("strdup:");