aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2019-01-23 09:21:08 -0500
committerLibravatar GitHub <noreply@github.com>2019-01-23 09:21:08 -0500
commit8b056cfc82ac14a3b566b344c2d9ad983f2cdbb4 (patch)
treef94b30fe275b0c6fe46cc73fcb459b691d31a651 /swaybar
parentMerge pull request #3502 from lukaslihotzki/master (diff)
parentswaybar: fix crash with some tray icon pixmaps (diff)
downloadsway-8b056cfc82ac14a3b566b344c2d9ad983f2cdbb4.tar.gz
sway-8b056cfc82ac14a3b566b344c2d9ad983f2cdbb4.tar.zst
sway-8b056cfc82ac14a3b566b344c2d9ad983f2cdbb4.zip
Merge pull request #3500 from progandy/validate_pixmaps
swaybar: fix crash with some tray icon pixmaps
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 02e34ed5..4262d687 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,