From 51739ee96dc6315a46f63b952afeb1f047ef3f56 Mon Sep 17 00:00:00 2001 From: Felix Lu Date: Tue, 26 Apr 2016 16:48:27 -0400 Subject: [PATCH] monitor mode: bugfix Fix an off by 1 error and always flush output. --- staprun/monitor.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/staprun/monitor.c b/staprun/monitor.c index 0f806e1d6..45fabbb0e 100644 --- a/staprun/monitor.c +++ b/staprun/monitor.c @@ -541,7 +541,7 @@ void monitor_input(void) char *p = h_queue.linebuf; /* scan position */ char *p_end = h_queue.linebuf + h_queue.linebuf_ptr + bytes; /* one past last byte */ char *line = p; - while (p <= p_end) + while (p < p_end) { if (*p == '\n') /* got a line */ { @@ -551,19 +551,10 @@ void monitor_input(void) p ++; } - if (line != p) - { - /* Move trailing partial line (if any) to front of buffer. */ - memmove (h_queue.linebuf, line, (p_end - line)); - h_queue.linebuf_ptr = (p_end - line); - } - else - { - /* No line found in entire buffer! Pretend it was all one line. */ - monitor_remember_output_line(line, (p_end - line)); - h_queue.linebuf_ptr = 0; - } - } + /* Flush remaining output */ + monitor_remember_output_line(line, (p_end - line)); + h_queue.linebuf_ptr = 0; + } getmaxyx(monitor_output, max_rows, max_cols); getyx(monitor_status, cur_y, cur_x); -- 2.43.5