summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-11-20 11:07:30 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-11-20 11:07:30 -0800
commitbed46b55c06a3488971fda8271cf9fc0e3dd84d5 (patch)
tree9732abdd83e0b9533f130d446f633c07d1ba5661
parentc71236d5ae587f6a673a8bf1b6fd5de64a3ba78c (diff)
downloadxorg-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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/XRes.c b/src/XRes.c
index d061dd7..af89f77 100644
--- a/src/XRes.c
+++ b/src/XRes.c
@@ -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;