getline: add check for len > 0
This condition cannot happen here though.
This commit is contained in:
1 parent
7c0334de3d
commit
bfb071698a
1 file changed
+1
-1
@@ -562,7 +562,7 @@ readstdin(void)
|
|||||||
if (!(items = realloc(items, itemsiz * sizeof(*items))))
|
if (!(items = realloc(items, itemsiz * sizeof(*items))))
|
||||||
die("cannot realloc %zu bytes:", 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';
|
line[len - 1] = '\0';
|
||||||
if (!(items[i].text = strdup(line)))
|
if (!(items[i].text = strdup(line)))
|
||||||
die("strdup:");
|
die("strdup:");
|
||||||
|
|||||||
Reference in new issue
Block a user