Module Name:    src
Committed By:   dholland
Date:           Wed Aug 29 18:50:36 UTC 2012

Modified Files:
        src/lib/libc/gen: getgrent.c

Log Message:
Check for NULL *before* using ALIGN().

I don't remember what prompted this, but it's obviously a desirable fix
and I've been carrying it on a heavily-used machine for more than a year.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/lib/libc/gen/getgrent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/getgrent.c
diff -u src/lib/libc/gen/getgrent.c:1.66 src/lib/libc/gen/getgrent.c:1.67
--- src/lib/libc/gen/getgrent.c:1.66	Thu Mar 29 13:05:10 2012
+++ src/lib/libc/gen/getgrent.c	Wed Aug 29 18:50:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: getgrent.c,v 1.66 2012/03/29 13:05:10 christos Exp $	*/
+/*	$NetBSD: getgrent.c,v 1.67 2012/08/29 18:50:35 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999-2000, 2004-2005 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
 #if 0
 static char sccsid[] = "@(#)getgrent.c	8.2 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: getgrent.c,v 1.66 2012/03/29 13:05:10 christos Exp $");
+__RCSID("$NetBSD: getgrent.c,v 1.67 2012/08/29 18:50:35 dholland Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -221,9 +221,9 @@ _gr_parse(const char *entry, struct grou
 	}
 				/* grab ALIGNed char **gr_mem from buf */
 	ep = _gr_memfrombuf(memc * sizeof(char *) + ALIGNBYTES, &buf, &buflen);
-	grp->gr_mem = (char **)ALIGN(ep);
-	if (grp->gr_mem == NULL)
+	if (ep == NULL)
 		return 0;
+	grp->gr_mem = (char **)ALIGN(ep);
 
 	for (memc = 0; *entry != '\0'; memc++) {
 		count = strcspn(entry, ",");	/* parse member */

Reply via email to