aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar
diff options
context:
space:
mode:
authorLibravatar progandy <code@progandy>2019-01-22 21:07:35 +0100
committerLibravatar progandy <code@progandy>2019-01-23 00:04:00 +0100
commitdcabe0e6da0c0445252fe74b5ef96fed640fa791 (patch)
tree085042f3b7c4ad54c1d8bb3686d556bc37817ad3 /swaybar
parentbackground-image.c: remove stdbool header (diff)
downloadsway-dcabe0e6da0c0445252fe74b5ef96fed640fa791.tar.gz
sway-dcabe0e6da0c0445252fe74b5ef96fed640fa791.tar.zst
sway-dcabe0e6da0c0445252fe74b5ef96fed640fa791.zip
swaybar: fix crash with some tray icon pixmaps
Discard pixmaps for icons where width and height are 0 or not equal. Fixes #3487
Diffstat (limited to 'swaybar')
-rw-r--r--swaybar/tray/item.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/swaybar/tray/item.c b/swaybar/tray/item.c
index a43bbf6f..a3a7240e 100644
--- a/swaybar/tray/item.c
+++ b/swaybar/tray/item.c
@@ -56,8 +56,8 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
56 goto error; 56 goto error;
57 } 57 }
58 58
59 int size; 59 int width, height;
60 ret = sd_bus_message_read(msg, "ii", NULL, &size); 60 ret = sd_bus_message_read(msg, "ii", &width, &height);
61 if (ret < 0) { 61 if (ret < 0) {
62 sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); 62 sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret));
63 goto error; 63 goto error;
@@ -71,14 +71,25 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
71 goto error; 71 goto error;
72 } 72 }
73 73
74 struct swaybar_pixmap *pixmap = 74 if (height > 0 && width == height) {
75 malloc(sizeof(struct swaybar_pixmap) + npixels); 75 sway_log(SWAY_DEBUG, "%s %s: found icon w:%d h:%d", sni->watcher_id, prop, width, height);
76 pixmap->size = size; 76 struct swaybar_pixmap *pixmap =
77 memcpy(pixmap->pixels, pixels, npixels); 77 malloc(sizeof(struct swaybar_pixmap) + npixels);
78 list_add(pixmaps, pixmap); 78 pixmap->size = height;
79 memcpy(pixmap->pixels, pixels, npixels);
80 list_add(pixmaps, pixmap);
81 } else {
82 sway_log(SWAY_DEBUG, "%s %s: discard invalid icon w:%d h:%d", sni->watcher_id, prop, width, height);
83 }
79 84
80 sd_bus_message_exit_container(msg); 85 sd_bus_message_exit_container(msg);
81 } 86 }
87
88 if (pixmaps->length < 1) {
89 sway_log(SWAY_DEBUG, "%s %s no. of icons = 0", sni->watcher_id, prop);
90 goto error;
91 }
92
82 list_free_items_and_destroy(*dest); 93 list_free_items_and_destroy(*dest);
83 *dest = pixmaps; 94 *dest = pixmaps;
84 sway_log(SWAY_DEBUG, "%s %s no. of icons = %d", sni->watcher_id, prop, 95 sway_log(SWAY_DEBUG, "%s %s no. of icons = %d", sni->watcher_id, prop,