diff options
author | truckman <truckman@FreeBSD.org> | 2016-06-15 06:42:30 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2016-06-15 06:42:30 +0000 |
commit | ea478cdf17b092127d850c94d192e06567a49ee6 (patch) | |
tree | b14af450dba03f2c524b5b64e5ccf57a5b71e370 /lib/libc/gen | |
parent | f4be65f8e03969bff13944ac444c0281c70d9a1f (diff) | |
download | FreeBSD-src-ea478cdf17b092127d850c94d192e06567a49ee6.zip FreeBSD-src-ea478cdf17b092127d850c94d192e06567a49ee6.tar.gz |
MFC r301596
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
Differential Revision: https://reviews.freebsd.org/D6755
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/getnetgrent.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index 4bf0a14..8aa75e2 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -615,6 +615,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) { |