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.
This commit is contained in:
dholland 2012-08-29 18:50:35 +00:00
parent 06b26cd86b
commit 8c41afe697
1 changed files with 4 additions and 4 deletions

View File

@ -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 */