aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-23 09:21:08 -0500
committerGitHub <noreply@github.com>2019-01-23 09:21:08 -0500
commit8b056cfc82ac14a3b566b344c2d9ad983f2cdbb4 (patch)
treef94b30fe275b0c6fe46cc73fcb459b691d31a651
parent1803e7748bbfa8e28050e5aa906fcd7bb95e5ea1 (diff)
parentdcabe0e6da0c0445252fe74b5ef96fed640fa791 (diff)
downloadsway-8b056cfc82ac14a3b566b344c2d9ad983f2cdbb4.zip
sway-8b056cfc82ac14a3b566b344c2d9ad983f2cdbb4.tar.gz
sway-8b056cfc82ac14a3b566b344c2d9ad983f2cdbb4.tar.bz2
Merge pull request #3500 from progandy/validate_pixmaps
swaybar: fix crash with some tray icon pixmaps
-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 02e34ed..4262d68 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,
goto error;
}
- int size;
- ret = sd_bus_message_read(msg, "ii", NULL, &size);
+ int width, height;
+ ret = sd_bus_message_read(msg, "ii", &width, &height);
if (ret < 0) {
sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret));
goto error;
@@ -71,14 +71,25 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
goto error;
}
- struct swaybar_pixmap *pixmap =
- malloc(sizeof(struct swaybar_pixmap) + npixels);
- pixmap->size = size;
- memcpy(pixmap->pixels, pixels, npixels);
- list_add(pixmaps, pixmap);
+ if (height > 0 && width == height) {
+ sway_log(SWAY_DEBUG, "%s %s: found icon w:%d h:%d", sni->watcher_id, prop, width, height);
+ struct swaybar_pixmap *pixmap =
+ malloc(sizeof(struct swaybar_pixmap) + npixels);
+ pixmap->size = height;
+ memcpy(pixmap->pixels, pixels, npixels);
+ list_add(pixmaps, pixmap);
+ } else {
+ sway_log(SWAY_DEBUG, "%s %s: discard invalid icon w:%d h:%d", sni->watcher_id, prop, width, height);
+ }
sd_bus_message_exit_container(msg);
}
+
+ if (pixmaps->length < 1) {
+ sway_log(SWAY_DEBUG, "%s %s no. of icons = 0", sni->watcher_id, prop);
+ goto error;
+ }
+
list_free_items_and_destroy(*dest);
*dest = pixmaps;
sway_log(SWAY_DEBUG, "%s %s no. of icons = %d", sni->watcher_id, prop,