diff options
author | Person <you@example.com> | 2023-03-15 15:01:57 -0500 |
---|---|---|
committer | Person <you@example.com> | 2023-03-15 15:01:57 -0500 |
commit | 9a1d37c83b3e6df17494955107eda8437a454ab0 (patch) | |
tree | f422149f45bddfe10ecd0d9aa81965fc7457a4dc /dmenu.c | |
parent | 5773a77780fee2424ad561c1c83136f45e2b1a67 (diff) | |
parent | dfbbf7f6e1b22ccf9e5a45d77ee10995577fb4fc (diff) |
Diffstat (limited to 'dmenu.c')
-rw-r--r-- | dmenu.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -589,11 +589,11 @@ static void readstdin(void) { char *line = NULL; - size_t i, junk, itemsiz = 0; + size_t i, itemsiz = 0, linesiz = 0; ssize_t len; /* read each line from stdin and add it to the item list */ - for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++) { + for (i = 0; (len = getline(&line, &linesiz, stdin)) != -1; i++) { if (i + 1 >= itemsiz) { itemsiz += 256; if (!(items = realloc(items, itemsiz * sizeof(*items)))) @@ -601,9 +601,10 @@ readstdin(void) } if (line[len - 1] == '\n') line[len - 1] = '\0'; - items[i].text = line; + if (!(items[i].text = strdup(line))) + die("strdup:"); + items[i].out = 0; - line = NULL; /* next call of getline() allocates a new line */ } free(line); if (items) |