diff options
author | Milkey Mouse <milkeymouse@meme.institute> | 2020-05-20 13:57:56 -0700 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-20 23:11:02 +0200 |
commit | 45e4e9217238fe658b99634d284768439969ad79 (patch) | |
tree | ef94c0728b949a1fba90d76e0e16d37a0271fdf3 | |
parent | sway.5: make formatting more consistent (diff) | |
download | sway-45e4e9217238fe658b99634d284768439969ad79.tar.gz sway-45e4e9217238fe658b99634d284768439969ad79.tar.zst sway-45e4e9217238fe658b99634d284768439969ad79.zip |
swaybar: add NULL check when listing workspaces
For some reason my version of sway doesn't show workspace names:
$ swaymsg -t get_outputs
Output HDMI-A-1 '(null) (null) (null)' (inactive)
Output HDMI-A-2 '(null) (null) (null)' (inactive)
Which is weird, but it's no reason to crash swaybar. The field is
totally missing from the JSON, so it ends up doing strcmp(NULL, name)
which is undefined behavior.
-rw-r--r-- | swaybar/ipc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/swaybar/ipc.c b/swaybar/ipc.c index f3b7dd3d..6aa604eb 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c | |||
@@ -360,7 +360,7 @@ bool ipc_get_workspaces(struct swaybar *bar) { | |||
360 | 360 | ||
361 | wl_list_for_each(output, &bar->outputs, link) { | 361 | wl_list_for_each(output, &bar->outputs, link) { |
362 | const char *ws_output = json_object_get_string(out); | 362 | const char *ws_output = json_object_get_string(out); |
363 | if (strcmp(ws_output, output->name) == 0) { | 363 | if (ws_output != NULL && strcmp(ws_output, output->name) == 0) { |
364 | struct swaybar_workspace *ws = | 364 | struct swaybar_workspace *ws = |
365 | calloc(1, sizeof(struct swaybar_workspace)); | 365 | calloc(1, sizeof(struct swaybar_workspace)); |
366 | ws->num = json_object_get_int(num); | 366 | ws->num = json_object_get_int(num); |