From 785d049f7ab417afc7c4d3d65c91f298125fbc16 Mon Sep 17 00:00:00 2001
From: George Kiagiadakis <george.kiagiadakis@collabora.com>
Date: Fri, 26 Jun 2020 19:05:58 +0300
Subject: [PATCH] main: fix call to g_input_stream_read after reaching the end
 of the buffer

after consuming the whole buffer, cur & linestart need to
be reset to point back to the beginning of the local buffer
---
 src/main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main.c b/src/main.c
index 8ec03a28..5ad9b96b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -324,6 +324,9 @@ parse_commands_file (struct WpDaemonData *d, GInputStream * stream,
       strncpy (buffer, linestart, cur - linestart);
       linestart = buffer;
       cur = buffer + (cur - linestart);
+    } else {
+      /* reset for the next g_input_stream_read() call */
+      linestart = cur = buffer;
     }
   } while (!eof);
 
-- 
GitLab