aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/status_line.c
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-09-22 10:57:22 +0100
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-09-22 11:02:47 +0100
commita4d346627cc661f32bc7fb65a43ff19d48b50a96 (patch)
tree9fe3ee50c17a53266183e1e4643bb149c6af6c86 /swaybar/status_line.c
parentMerge pull request #2679 from RyanDwyer/fix-pango-escaping (diff)
downloadsway-a4d346627cc661f32bc7fb65a43ff19d48b50a96.tar.gz
sway-a4d346627cc661f32bc7fb65a43ff19d48b50a96.tar.zst
sway-a4d346627cc661f32bc7fb65a43ff19d48b50a96.zip
swaybar: explicitly check return value of getdelim
This prevents an signed-to-unsigned conversion error on buffer_index if getdelim fails and returns -1, which caused swaybar to try to search the header for the array and immediately failing
Diffstat (limited to 'swaybar/status_line.c')
-rw-r--r--swaybar/status_line.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/swaybar/status_line.c b/swaybar/status_line.c
index 401bf6f6..48b43248 100644
--- a/swaybar/status_line.c
+++ b/swaybar/status_line.c
@@ -67,9 +67,13 @@ bool status_handle_readable(struct status_line *status) {
67 67
68 wl_list_init(&status->blocks); 68 wl_list_init(&status->blocks);
69 status->tokener = json_tokener_new(); 69 status->tokener = json_tokener_new();
70 status->buffer_index = getdelim(&status->buffer, 70 read_bytes = getdelim(&status->buffer, &status->buffer_size, EOF, status->read);
71 &status->buffer_size, EOF, status->read); 71 if (read_bytes > 0) {
72 return i3bar_handle_readable(status); 72 status->buffer_index = read_bytes;
73 return i3bar_handle_readable(status);
74 } else {
75 return false;
76 }
73 } 77 }
74 78
75 wlr_log(WLR_DEBUG, "Using text protocol."); 79 wlr_log(WLR_DEBUG, "Using text protocol.");