From 8c41afe6970f3b9170e5e43d3586b1b6514b4856 Mon Sep 17 00:00:00 2001 From: dholland Date: Wed, 29 Aug 2012 18:50:35 +0000 Subject: [PATCH] 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. --- lib/libc/gen/getgrent.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index 1bd135a991f0..783446528f8d 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -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 group *grp, char *buf, size_t buflen) } /* 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 */