aboutsummaryrefslogtreecommitdiff
path: root/swaybar
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2018-09-21 14:59:01 +0100
committerFurkan Sahin <furkan-dev@proton.me>2018-09-21 14:59:01 +0100
commit563fe3f65fd64f01e345c7683cc2eaa5027853b1 (patch)
tree5499d14723fcc92cb3aecb5634d63c9fb062ed3f /swaybar
parent47287e7bab9052ff93c2883d98bb37b03971ad65 (diff)
swaybar: reset tokener if json is incomplete
If the tokener parses incomplete json, it sets its error value to json_tokener_continue. This means that extra json should be provided, but the code was providing the entire object again. In the interest of simplicity, the tokener is reset so that buffer_pos always points to the start of the current object.
Diffstat (limited to 'swaybar')
-rw-r--r--swaybar/i3bar.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c
index 4ea9c4c1..02b68a2a 100644
--- a/swaybar/i3bar.c
+++ b/swaybar/i3bar.c
@@ -199,6 +199,7 @@ bool i3bar_handle_readable(struct status_line *status) {
}
buffer_pos = status->buffer_index = 0;
} else if (json_tokener_get_error(status->tokener) == json_tokener_continue) {
+ json_tokener_reset(status->tokener);
if (status->buffer_index < status->buffer_size) {
// move the object to the start of the buffer
status->buffer_index -= buffer_pos;