summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2016-06-08 10:25:16 +0000
committertruckman <truckman@FreeBSD.org>2016-06-08 10:25:16 +0000
commit349a85b717907616671dafe151f333ef6fbce187 (patch)
tree91caf4e21a8b4375fded0566a64e61be3ca6891f /lib/libc
parentc38d1274830f543016a498792c1407170e4a6717 (diff)
downloadFreeBSD-src-349a85b717907616671dafe151f333ef6fbce187.zip
FreeBSD-src-349a85b717907616671dafe151f333ef6fbce187.tar.gz
Don't leak olinep if malloc() fails.
If malloc() fails to allocate linep, then free olinep (if it exists) before returning to avoid a memory leak. Reported by: Coverity CID: 1016716 Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6755
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getnetgrent.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index 0dcf2a2..71a36e2 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -614,6 +614,8 @@ read_for_group(const char *group)
if (linep == NULL) {
free(lp->l_groupname);
free(lp);
+ if (olen > 0)
+ free(olinep);
return (NULL);
}
if (olen > 0) {
OpenPOWER on IntegriCloud