[hackers] [dmenu] getline: add check for len > 0 || Hiltjo Posthuma

From: git=suckless.org via suckless hackers list <hackers_at_suckless.org>
Date: Tue, 27 Oct 2026 21:14:02 +0100 (CET)

commit bfb071698a2b5889497a9e6a082b6ba114dad0ef
Author: Hiltjo Posthuma <hiltjo_at_codemadness.org>
AuthorDate: Tue Oct 27 21:10:35 2026 +0100
Commit: Hiltjo Posthuma <hiltjo_at_codemadness.org>
CommitDate: Tue Oct 27 21:10:35 2026 +0100

    getline: add check for len > 0
    
    This condition cannot happen here though.

diff --git a/dmenu.c b/dmenu.c
index 07ab089..9fa7f0b 100644
--- a/dmenu.c
+++ b/dmenu.c
_at_@ -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:");
Received on Tue Oct 27 2026 - 21:14:02 CET

This archive was generated by hypermail 2.3.0 : Tue Oct 27 2026 - 21:24:40 CET