diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-11-20 11:07:30 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-11-20 11:07:30 -0800 |
commit | bed46b55c06a3488971fda8271cf9fc0e3dd84d5 (patch) | |
tree | 9732abdd83e0b9533f130d446f633c07d1ba5661 | |
parent | c71236d5ae587f6a673a8bf1b6fd5de64a3ba78c (diff) | |
download | xorg-lib-libXRes-bed46b55c06a3488971fda8271cf9fc0e3dd84d5.tar.gz |
Use calloc instead of malloc to allocate arrays
Makes code more consistent with other functions in this library
which already do this and adds extra protection against overflows
or failures to properly fill in values.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | src/XRes.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -113,7 +113,7 @@ XResQueryClients(Display *dpy, int *num_clients, XResClient **clients) XResClient *clnts; if (rep.num_clients < (INT_MAX / sizeof(XResClient))) - clnts = Xmalloc(sizeof(XResClient) * rep.num_clients); + clnts = Xcalloc(rep.num_clients, sizeof(XResClient)); else clnts = NULL; @@ -168,7 +168,7 @@ XResQueryClientResources(Display *dpy, XID xid, XResType *typs; if (rep.num_types < (INT_MAX / sizeof(XResType))) - typs = Xmalloc(sizeof(XResType) * rep.num_types); + typs = Xcalloc(rep.num_types, sizeof(XResType)); else typs = NULL; |