mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
replace a few (x)malloc with (x)calloc to prevent potential integer
overflows; from Tiago Cunha
This commit is contained in:
parent
7a7e5cd592
commit
fe439f2b96
4
group.c
4
group.c
@ -430,8 +430,8 @@ group_update_names(struct screen_ctx *sc)
|
||||
}
|
||||
}
|
||||
|
||||
strings = xmalloc((nstrings < CALMWM_NGROUPS ? CALMWM_NGROUPS :
|
||||
nstrings) * sizeof(*strings));
|
||||
strings = xcalloc((nstrings < CALMWM_NGROUPS ? CALMWM_NGROUPS :
|
||||
nstrings), sizeof(*strings));
|
||||
|
||||
p = (char *)prop_ret;
|
||||
while (n < nstrings) {
|
||||
|
6
xutil.c
6
xutil.c
@ -291,7 +291,7 @@ xu_ewmh_net_client_list(struct screen_ctx *sc)
|
||||
if (i == 0)
|
||||
return;
|
||||
|
||||
winlist = xmalloc(i * sizeof(*winlist));
|
||||
winlist = xcalloc(i, sizeof(*winlist));
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
winlist[j++] = cc->win;
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CLIENT_LIST].atom,
|
||||
@ -382,7 +382,7 @@ xu_ewmh_get_net_wm_state(struct client_ctx *cc, int *n)
|
||||
(u_char **)&p)) <= 0)
|
||||
return (NULL);
|
||||
|
||||
state = xmalloc(*n * sizeof(Atom));
|
||||
state = xcalloc(*n, sizeof(Atom));
|
||||
memcpy(state, p, *n * sizeof(Atom));
|
||||
XFree((char *)p);
|
||||
|
||||
@ -449,7 +449,7 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc)
|
||||
int n, i, j;
|
||||
|
||||
oatoms = xu_ewmh_get_net_wm_state(cc, &n);
|
||||
atoms = xmalloc((n + _NET_WM_STATES_NITEMS) * sizeof(Atom));
|
||||
atoms = xcalloc((n + _NET_WM_STATES_NITEMS), sizeof(Atom));
|
||||
for (i = j = 0; i < n; i++) {
|
||||
if (oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ].atom &&
|
||||
oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT].atom)
|
||||
|
Loading…
Reference in New Issue
Block a user