From dbff29c81d3127d69e97abcf7001f4b798898a81 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 4 Sep 2013 13:37:38 +0200 Subject: x11_common: don't allocate more than needed for icon icon_size is the number of array items of type long, not bytes. Change the type of icon_size to int, because size_t makes you think of byte quantities too quickly. As an unrelated change, change the (char *) cast to (unsigned char *), because it matches the common XChangeProperty idiom better. --- video/out/x11_common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'video') diff --git a/video/out/x11_common.c b/video/out/x11_common.c index af83c6a53e..c8716d0a55 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -1029,9 +1029,9 @@ static void vo_x11_set_wm_icon(struct vo_x11_state *x11) } } - size_t icon_size = 0; + int icon_size = 0; for (int n = 0; n < num_icons; n++) - icon_size += sizeof(long) * (2 + icon_w[n] * icon_h[n]); + icon_size += 2 + icon_w[n] * icon_h[n]; long *icon = talloc_array(NULL, long, icon_size); long *cur = icon; for (int n = 0; n < num_icons; n++) { @@ -1043,7 +1043,8 @@ static void vo_x11_set_wm_icon(struct vo_x11_state *x11) } XChangeProperty(x11->display, x11->window, x11->XA_NET_WM_ICON, - XA_CARDINAL, 32, PropModeReplace, (char *)icon, icon_size); + XA_CARDINAL, 32, PropModeReplace, + (unsigned char *)icon, icon_size); talloc_free(icon); talloc_free(uncompressed.start); } -- cgit v1.2.3