summaryrefslogtreecommitdiff
path: root/dmenu.c
diff options
context:
space:
mode:
authorPerson <you@example.com>2023-03-15 15:01:57 -0500
committerPerson <you@example.com>2023-03-15 15:01:57 -0500
commit9a1d37c83b3e6df17494955107eda8437a454ab0 (patch)
treef422149f45bddfe10ecd0d9aa81965fc7457a4dc /dmenu.c
parent5773a77780fee2424ad561c1c83136f45e2b1a67 (diff)
parentdfbbf7f6e1b22ccf9e5a45d77ee10995577fb4fc (diff)
Merge branch 'master' of git://git.suckless.org/dmenuHEADmaster
Diffstat (limited to 'dmenu.c')
-rw-r--r--dmenu.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/dmenu.c b/dmenu.c
index acb4787..e45070f 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -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)