summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2014-10-25 17:18:41 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2014-10-25 17:18:41 +0300
commit2820734ec01ad6d2e1a0611fa480c3dd533588c7 (patch)
tree0d24917320b18c7bf4e9ad2d1b89167ad0e4d0da /client
parentb03cd1ea5329a0e7e2e435de827108c7d00265b5 (diff)
downloadbemenu-2820734ec01ad6d2e1a0611fa480c3dd533588c7.tar.gz
bemenu-2820734ec01ad6d2e1a0611fa480c3dd533588c7.tar.bz2
bemenu-2820734ec01ad6d2e1a0611fa480c3dd533588c7.zip
Fix stdin read.
Diffstat (limited to 'client')
-rw-r--r--client/client.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/client/client.c b/client/client.c
index 9d9a3a4..95c270e 100644
--- a/client/client.c
+++ b/client/client.c
@@ -234,10 +234,14 @@ read_items_to_menu_from_stdin(struct bm_menu *menu)
}
buffer[allocated - step + read - 1] = 0;
- size_t pos;
char *s = buffer;
- while ((pos = strcspn(s, "\n")) != 0) {
- size_t next = pos + (s[pos] != 0);
+ while ((size_t)(s - buffer) < allocated - step + read) {
+ size_t pos = strcspn(s, "\n");
+ if (pos == 0) {
+ s += 1;
+ continue;
+ }
+
s[pos] = 0;
struct bm_item *item;
@@ -245,7 +249,7 @@ read_items_to_menu_from_stdin(struct bm_menu *menu)
break;
bm_menu_add_item(menu, item);
- s += next;
+ s += pos + 1;
}
free(buffer);