mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
266ce242c3
commit
dbff29c81d
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue