diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index b0c427d0c2a3..814ca36a76db 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -1,4 +1,4 @@ -/* $NetBSD: getgrent.c,v 1.16 1997/05/20 15:46:03 lukem Exp $ */ +/* $NetBSD: getgrent.c,v 1.17 1997/05/21 01:51:39 lukem Exp $ */ /* * Copyright (c) 1989, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)getgrent.c 8.2 (Berkeley) 3/21/94"; #else -static char rcsid[] = "$NetBSD: getgrent.c,v 1.16 1997/05/20 15:46:03 lukem Exp $"; +static char rcsid[] = "$NetBSD: getgrent.c,v 1.17 1997/05/21 01:51:39 lukem Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -189,12 +189,16 @@ grscan(search, gid, name) case YPMODE_FULL: data = NULL; if (__ypcurrent) { + key = NULL; r = yp_next(__ypdomain, "group.byname", __ypcurrent, __ypcurrentlen, &key, &keylen, &data, &datalen); free(__ypcurrent); - if (r != 0) + if (r != 0) { __ypcurrent = NULL; + if (key) + free(key); + } else { __ypcurrent = key; __ypcurrentlen = keylen; diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index f525201a7fb9..a9cefffa152c 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -1,4 +1,4 @@ -/* $NetBSD: getpwent.c,v 1.17 1997/05/20 15:59:59 lukem Exp $ */ +/* $NetBSD: getpwent.c,v 1.18 1997/05/21 01:51:40 lukem Exp $ */ /* * Copyright (c) 1988, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)getpwent.c 8.1 (Berkeley) 6/4/93"; #else -static char rcsid[] = "$NetBSD: getpwent.c,v 1.17 1997/05/20 15:59:59 lukem Exp $"; +static char rcsid[] = "$NetBSD: getpwent.c,v 1.18 1997/05/21 01:51:40 lukem Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -292,12 +292,16 @@ again: case YPMODE_FULL: data = NULL; if(__ypcurrent) { + key = NULL; r = yp_next(__ypdomain, "passwd.byname", __ypcurrent, __ypcurrentlen, &key, &keylen, &data, &datalen); free(__ypcurrent); - if(r != 0) + if(r != 0) { __ypcurrent = NULL; + if (key) + free(key); + } else { __ypcurrent = key; __ypcurrentlen = keylen;