Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/su su(1): use reallocarr instead of malloc(x * y)



details:   https://anonhg.NetBSD.org/src/rev/4f35ab5f75d4
branches:  trunk
changeset: 990563:4f35ab5f75d4
user:      nia <nia%NetBSD.org@localhost>
date:      Sat Oct 30 11:25:30 2021 +0000

description:
su(1): use reallocarr instead of malloc(x * y)

diffstat:

 usr.bin/su/su.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r eb6c00f59fcd -r 4f35ab5f75d4 usr.bin/su/su.c
--- a/usr.bin/su/su.c   Sat Oct 30 11:23:07 2021 +0000
+++ b/usr.bin/su/su.c   Sat Oct 30 11:25:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: su.c,v 1.73 2021/10/17 10:33:57 nia Exp $      */
+/*     $NetBSD: su.c,v 1.74 2021/10/30 11:25:30 nia Exp $      */
 
 /*
  * Copyright (c) 1988 The Regents of the University of California.
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)su.c       8.3 (Berkeley) 4/2/94";*/
 #else
-__RCSID("$NetBSD: su.c,v 1.73 2021/10/17 10:33:57 nia Exp $");
+__RCSID("$NetBSD: su.c,v 1.74 2021/10/30 11:25:30 nia Exp $");
 #endif
 #endif /* not lint */
 
@@ -569,7 +569,8 @@
         * each member to see if it is a group, and if so whether user is
         * in it.
         */
-       gr_mem = emalloc((n + 1) * sizeof (char *));
+       gr_mem = NULL;
+       ereallocarr(&gr_mem, n + 1, sizeof(char *));
        for (g = gr->gr_mem, i = 0; *g; ++g) {
                gr_mem[i] = estrdup(*g);
                i++;



Home | Main Index | Thread Index | Old Index