=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/users/users.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- src/usr.bin/users/users.c 2003/06/03 02:56:21 1.7 +++ src/usr.bin/users/users.c 2003/10/16 16:57:37 1.8 @@ -1,4 +1,4 @@ -/* $OpenBSD: users.c,v 1.7 2003/06/03 02:56:21 millert Exp $ */ +/* $OpenBSD: users.c,v 1.8 2003/10/16 16:57:37 tedu Exp $ */ /* $NetBSD: users.c,v 1.5 1994/12/20 15:58:19 jtc Exp $ */ /* @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)users.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: users.c,v 1.7 2003/06/03 02:56:21 millert Exp $"; +static char rcsid[] = "$OpenBSD: users.c,v 1.8 2003/10/16 16:57:37 tedu Exp $"; #endif /* not lint */ #include @@ -82,14 +82,18 @@ while (fread((char *)&utmp, sizeof(utmp), 1, stdin) == 1) { if (*utmp.ut_name) { if (ncnt >= nmax) { - nmax += 32; - names = realloc(names, - sizeof (*names) * nmax); + size_t newmax = nmax + 32; + namebuf *newnames; - if (!names) { + newnames = realloc(names, + sizeof(*names) * newmax); + + if (newnames == NULL) { err(1, NULL); /* NOTREACHED */ } + names = newnames; + nmax = newmax; } (void)strncpy(names[ncnt], utmp.ut_name, UT_NAMESIZE);