Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/finger finger(1): convert malloc(x * y) to reallocarr



details:   https://anonhg.NetBSD.org/src/rev/52c9113ad8ea
branches:  trunk
changeset: 990542:52c9113ad8ea
user:      nia <nia%NetBSD.org@localhost>
date:      Sat Oct 30 09:12:09 2021 +0000

description:
finger(1): convert malloc(x * y) to reallocarr

diffstat:

 usr.bin/finger/finger.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r 0e2914bccda0 -r 52c9113ad8ea usr.bin/finger/finger.c
--- a/usr.bin/finger/finger.c   Sat Oct 30 09:06:34 2021 +0000
+++ b/usr.bin/finger/finger.c   Sat Oct 30 09:12:09 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: finger.c,v 1.30 2016/09/05 00:40:28 sevan Exp $        */
+/*     $NetBSD: finger.c,v 1.31 2021/10/30 09:12:09 nia Exp $  */
 
 /*
  * Copyright (c) 1989, 1993
@@ -52,7 +52,7 @@
 #if 0
 static char sccsid[] = "@(#)finger.c   8.5 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: finger.c,v 1.30 2016/09/05 00:40:28 sevan Exp $");
+__RCSID("$NetBSD: finger.c,v 1.31 2021/10/30 09:12:09 nia Exp $");
 #endif
 #endif /* not lint */
 
@@ -226,8 +226,10 @@
        char **ap, **nargv, **np, **p;
        struct utmpentry *ep;
 
-       if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL ||
-           (used = calloc(argc, sizeof(int))) == NULL)
+       nargv = NULL;
+       if (reallocarr(&nargv, argc + 1, sizeof(char *)) != 0)
+               err(1, NULL);
+       if ((used = calloc(argc, sizeof(int))) == NULL)
                err(1, NULL);
 
        /* Pull out all network requests. */



Home | Main Index | Thread Index | Old Index