mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-27 21:58:16 +01:00
swaybar: fix crash with some tray icon pixmaps
Discard pixmaps for icons where width and height are 0 or not equal. Fixes #3487
This commit is contained in:
parent
d7d906c7fd
commit
dcabe0e6da
1 changed files with 18 additions and 7 deletions
|
@ -56,8 +56,8 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size;
|
int width, height;
|
||||||
ret = sd_bus_message_read(msg, "ii", NULL, &size);
|
ret = sd_bus_message_read(msg, "ii", &width, &height);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret));
|
sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret));
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -71,14 +71,25 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct swaybar_pixmap *pixmap =
|
if (height > 0 && width == height) {
|
||||||
malloc(sizeof(struct swaybar_pixmap) + npixels);
|
sway_log(SWAY_DEBUG, "%s %s: found icon w:%d h:%d", sni->watcher_id, prop, width, height);
|
||||||
pixmap->size = size;
|
struct swaybar_pixmap *pixmap =
|
||||||
memcpy(pixmap->pixels, pixels, npixels);
|
malloc(sizeof(struct swaybar_pixmap) + npixels);
|
||||||
list_add(pixmaps, pixmap);
|
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);
|
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);
|
list_free_items_and_destroy(*dest);
|
||||||
*dest = pixmaps;
|
*dest = pixmaps;
|
||||||
sway_log(SWAY_DEBUG, "%s %s no. of icons = %d", sni->watcher_id, prop,
|
sway_log(SWAY_DEBUG, "%s %s no. of icons = %d", sni->watcher_id, prop,
|
||||||
|
|
Loading…
Reference in a new issue