getline: add check for len > 0

This condition cannot happen here though.
This commit is contained in:
Hiltjo Posthuma committed 2026-10-27 21:10:35 +01:00
1 parent 7c0334de3d
commit bfb071698a
1 file changed
+1 -1
+1 -1
View File
@@ -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:");