summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2018-01-18 14:28:12 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2018-01-18 14:28:12 +0000
commitf4232a7930f91d2beea0a88a0587a97f34914dbb (patch)
tree6f2f6becb214c1dcfe84a9982104442951ec4a13 /usr.bin
parentb8149ca9e9a9eb02e2af69ce0615f6e85346e5e9 (diff)
Discard all but the last line when reading from a #() command - the
callback is just going to be fired again straight away to go through all the lines, it is better just to use the last one straight away.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/format.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index 9b310e9ee9e..c2b7f215fcc 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.150 2017/11/02 18:52:05 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.151 2018/01/18 14:28:11 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -191,10 +191,15 @@ static void
format_job_update(struct job *job)
{
struct format_job *fj = job->data;
- char *line;
+ struct evbuffer *evb = job->event->input;
+ char *line = NULL, *next;
time_t t;
- if ((line = evbuffer_readline(job->event->input)) == NULL)
+ while ((next = evbuffer_readline(evb)) != NULL) {
+ free(line);
+ line = next;
+ }
+ if (line == NULL)
return;
fj->updated = 1;