all repos — tint2 @ 82776df9d6b5e2003a4e9f41c65c01efc5d5a350

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Fix crash when _NET_WM_ICON is set but empty
o9000 mrovi9000@gmail.com
commit

82776df9d6b5e2003a4e9f41c65c01efc5d5a350

parent

f351b6fd8ef3e6a3150a24fec8fa10a1d39f6ab1

2 files changed, 20 insertions(+), 17 deletions(-)

jump to
M src/taskbar/task.csrc/taskbar/task.c

@@ -276,25 +276,25 @@

Imlib_Image img = NULL; if (!img) { - int i; - gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &i); - if (data) { + int len; + gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &len); + if (data && len > 0) { // get ARGB icon int w, h; - gulong *tmp_data; - - tmp_data = get_best_icon(data, get_icon_count(data, i), i, &w, &h, panel->g_task.icon_size1); - DATA32 icon_data[w * h]; - for (int j = 0; j < w * h; ++j) - icon_data[j] = tmp_data[j]; - img = imlib_create_image_using_copied_data(w, h, icon_data); - if (0 && img) - fprintf(stderr, - "%s: Got %dx%d icon via _NET_WM_ICON for %s\n", - __FUNCTION__, - w, - h, - task->title ? task->title : "task"); + gulong *tmp_data = get_best_icon(data, get_icon_count(data, len), len, &w, &h, panel->g_task.icon_size1); + if (tmp_data) { + DATA32 icon_data[w * h]; + for (int j = 0; j < w * h; ++j) + icon_data[j] = tmp_data[j]; + img = imlib_create_image_using_copied_data(w, h, icon_data); + if (0 && img) + fprintf(stderr, + "%s: Got %dx%d icon via _NET_WM_ICON for %s\n", + __FUNCTION__, + w, + h, + task->title ? task->title : "task"); + } XFree(data); } }
M src/util/window.csrc/util/window.c

@@ -277,6 +277,9 @@ }

gulong *get_best_icon(gulong *data, int icon_count, int num, int *iw, int *ih, int best_icon_size) { + if (icon_count < 1 || num < 1) + return NULL; + int width[icon_count], height[icon_count], pos, i, w, h; gulong *icon_data[icon_count];