aboutsummarylogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorHiltjo Posthuma2015-10-20 23:30:31 +0200
committerHiltjo Posthuma2015-10-20 23:38:31 +0200
commit80fe4dee99c405f301b37f94caf3ed2239d7fbc2 (patch)
tree53ffcf83645c9b362cdb773733ab2466f68c560e /dwm.c
parent1a98f49c9df1757650ced5cbe5c77800ff7463fb (diff)
downloadaur-80fe4dee99c405f301b37f94caf3ed2239d7fbc2.tar.gz
dwm: use ecalloc, prevent theoretical overflow
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/dwm.c b/dwm.c
index e2d74231a4ad..6295831b9760 100644
--- a/dwm.c
+++ b/dwm.c
@@ -630,8 +630,7 @@ Monitor *
createmon(void) {
Monitor *m;
- if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
- die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
+ m = ecalloc(1, sizeof(Monitor));
m->tagset[0] = m->tagset[1] = 1;
m->mfact = mfact;
m->nmaster = nmaster;
@@ -1007,8 +1006,7 @@ manage(Window w, XWindowAttributes *wa) {
Window trans = None;
XWindowChanges wc;
- if(!(c = calloc(1, sizeof(Client))))
- die("fatal: could not malloc() %u bytes\n", sizeof(Client));
+ c = ecalloc(1, sizeof(Client));
c->win = w;
updatetitle(c);
if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
@@ -1788,8 +1786,7 @@ updategeom(void) {
for(n = 0, m = mons; m; m = m->next, n++);
/* only consider unique geometries as separate screens */
- if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * nn)))
- die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * nn);
+ unique = ecalloc(nn, sizeof(XineramaScreenInfo));
for(i = 0, j = 0; i < nn; i++)
if(isuniquegeom(unique, j, &info[i]))
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));