mirror of
https://git.suckless.org/dwm
synced 2024-12-27 03:16:32 +00:00
dwm: use ecalloc, prevent theoretical overflow
This commit is contained in:
parent
04db03a4e6
commit
e3b7e1d620
1 changed files with 3 additions and 6 deletions
9
dwm.c
9
dwm.c
|
@ -630,8 +630,7 @@ Monitor *
|
||||||
createmon(void) {
|
createmon(void) {
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
|
||||||
if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
|
m = ecalloc(1, sizeof(Monitor));
|
||||||
die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
|
|
||||||
m->tagset[0] = m->tagset[1] = 1;
|
m->tagset[0] = m->tagset[1] = 1;
|
||||||
m->mfact = mfact;
|
m->mfact = mfact;
|
||||||
m->nmaster = nmaster;
|
m->nmaster = nmaster;
|
||||||
|
@ -1007,8 +1006,7 @@ manage(Window w, XWindowAttributes *wa) {
|
||||||
Window trans = None;
|
Window trans = None;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
if(!(c = calloc(1, sizeof(Client))))
|
c = ecalloc(1, sizeof(Client));
|
||||||
die("fatal: could not malloc() %u bytes\n", sizeof(Client));
|
|
||||||
c->win = w;
|
c->win = w;
|
||||||
updatetitle(c);
|
updatetitle(c);
|
||||||
if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
|
if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
|
||||||
|
@ -1788,8 +1786,7 @@ updategeom(void) {
|
||||||
|
|
||||||
for(n = 0, m = mons; m; m = m->next, n++);
|
for(n = 0, m = mons; m; m = m->next, n++);
|
||||||
/* only consider unique geometries as separate screens */
|
/* only consider unique geometries as separate screens */
|
||||||
if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * nn)))
|
unique = ecalloc(nn, sizeof(XineramaScreenInfo));
|
||||||
die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * nn);
|
|
||||||
for(i = 0, j = 0; i < nn; i++)
|
for(i = 0, j = 0; i < nn; i++)
|
||||||
if(isuniquegeom(unique, j, &info[i]))
|
if(isuniquegeom(unique, j, &info[i]))
|
||||||
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
|
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
|
||||||
|
|
Loading…
Reference in a new issue