Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/net getaddrinfo(3): malloc + memset -> calloc



details:   https://anonhg.NetBSD.org/src/rev/a3474386b976
branches:  trunk
changeset: 990459:a3474386b976
user:      nia <nia%NetBSD.org@localhost>
date:      Wed Oct 27 19:24:38 2021 +0000

description:
getaddrinfo(3): malloc + memset -> calloc

diffstat:

 lib/libc/net/getaddrinfo.c |  7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r b516823988cd -r a3474386b976 lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c        Wed Oct 27 19:04:03 2021 +0000
+++ b/lib/libc/net/getaddrinfo.c        Wed Oct 27 19:24:38 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getaddrinfo.c,v 1.120 2020/11/18 12:49:52 is Exp $     */
+/*     $NetBSD: getaddrinfo.c,v 1.121 2021/10/27 19:24:38 nia Exp $    */
 /*     $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $    */
 
 /*
@@ -55,7 +55,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getaddrinfo.c,v 1.120 2020/11/18 12:49:52 is Exp $");
+__RCSID("$NetBSD: getaddrinfo.c,v 1.121 2021/10/27 19:24:38 nia Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifndef RUMP_ACTION
@@ -717,9 +717,8 @@
                return n;
 
        /* allocate a temporary array for sort and initialization of it. */
-       if ((aio = malloc(sizeof(*aio) * n)) == NULL)
+       if ((aio = calloc(n, sizeof(*aio))) == NULL)
                return n;       /* give up reordering */
-       memset(aio, 0, sizeof(*aio) * n);
 
        /* retrieve address selection policy from the kernel */
        TAILQ_INIT(&policyhead);



Home | Main Index | Thread Index | Old Index