diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-06-10 16:21:59 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-06-10 16:21:59 -0700 |
commit | e6ff50b4634f2f2211997444a73d35277a0608d4 (patch) | |
tree | ed114d5f18eeb7c031445908a4261285bd2fd369 | |
parent | bba869e4ff5826d48ea409b4a8bf4ff7ad414453 (diff) | |
download | xorg-lib-libXext-e6ff50b4634f2f2211997444a73d35277a0608d4.tar.gz |
Use calloc instead of malloc if we may not initialize all the bytes
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | src/XEVI.c | 4 | ||||
-rw-r--r-- | src/XMultibuf.c | 2 | ||||
-rw-r--r-- | src/XSync.c | 2 | ||||
-rw-r--r-- | src/Xcup.c | 2 | ||||
-rw-r--r-- | src/Xdbe.c | 2 |
5 files changed, 6 insertions, 6 deletions
@@ -126,7 +126,7 @@ Status XeviGetVisualInfo( return BadValue; } if (!n_visual || !visual) { /* copy the all visual */ - temp_visual = Xmalloc(sz_VisualID32 * sz_info); + temp_visual = Xcalloc(sz_info, sz_VisualID32); n_visual = 0; for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++) if (notInList(temp_visual, n_visual, vinfo[vinfoIndex].visualid)) @@ -170,7 +170,7 @@ Status XeviGetVisualInfo( sz_xInfo = rep.n_info * sz_xExtendedVisualInfo; sz_conflict = rep.n_conflicts * sizeof(VisualID); sz_xConflict = rep.n_conflicts * sz_VisualID32; - *evi_return = Xmalloc(sz_info + sz_conflict); + *evi_return = Xcalloc(sz_info + sz_conflict, 1); temp_xInfo = Xmalloc(sz_xInfo); temp_conflict = Xmalloc(sz_xConflict); } else { diff --git a/src/XMultibuf.c b/src/XMultibuf.c index 28c2af4..5e05794 100644 --- a/src/XMultibuf.c +++ b/src/XMultibuf.c @@ -177,7 +177,7 @@ static Status event_to_wire (Display *dpy, XEvent *libevent, xEvent *netevent) * read_buffer_info - read Buffer Info descriptors from the net; if unable * to allocate memory, read junk to make sure that stream is clear. */ -#define TALLOC(type,count) Xmalloc ((unsigned) count * sizeof(type)) +#define TALLOC(type,count) Xcalloc ((unsigned) count, sizeof(type)) static XmbufBufferInfo *read_buffer_info (Display *dpy, int nbufs) { diff --git a/src/XSync.c b/src/XSync.c index 3077db2..2d330bd 100644 --- a/src/XSync.c +++ b/src/XSync.c @@ -358,7 +358,7 @@ XSyncListSystemCounters(Display *dpy, int *n_counters_return) int i; if (rep.nCounters < (INT_MAX / sizeof(XSyncSystemCounter))) - list = Xmalloc(rep.nCounters * sizeof(XSyncSystemCounter)); + list = Xcalloc(rep.nCounters, sizeof(XSyncSystemCounter)); if (rep.length < (INT_MAX >> 2)) { replylen = rep.length << 2; pWireSysCounter = Xmalloc (replylen + sizeof(XSyncCounter)); @@ -156,7 +156,7 @@ XcupGetReservedColormapEntries( } _XRead (dpy, (char*) rbufp, nbytes); - *colors_out = Xmalloc (nentries * sizeof (XColor)); + *colors_out = Xcalloc (nentries, sizeof (XColor)); if (*colors_out) { xColorItem* cs = (xColorItem *) rbufp; XColor* cd = *colors_out; @@ -348,7 +348,7 @@ XdbeScreenVisualInfo *XdbeGetVisualInfo ( /* allocate list of visual information to be returned */ if ((*num_screens > 0) && (*num_screens < 65536)) - scrVisInfo = Xmalloc(*num_screens * sizeof(XdbeScreenVisualInfo)); + scrVisInfo = Xcalloc(*num_screens, sizeof(XdbeScreenVisualInfo)); else scrVisInfo = NULL; if (scrVisInfo == NULL) { |