diff options
author | Don Lewis <truckman@FreeBSD.org> | 2016-06-08 10:25:16 +0000 |
---|---|---|
committer | Don Lewis <truckman@FreeBSD.org> | 2016-06-08 10:25:16 +0000 |
commit | 2b34ca7d10b73a8d9b89149689d7e304065a3cbe (patch) | |
tree | 91caf4e21a8b4375fded0566a64e61be3ca6891f /lib/libc/gen/getnetgrent.c | |
parent | d7f12eacbb83d29537403ca911692790eb44ce45 (diff) | |
download | src-2b34ca7d10b73a8d9b89149689d7e304065a3cbe.tar.gz src-2b34ca7d10b73a8d9b89149689d7e304065a3cbe.zip |
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
Notes
Notes:
svn path=/head/; revision=301596
Diffstat (limited to 'lib/libc/gen/getnetgrent.c')
-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 0dcf2a2ebd82..71a36e25bba6 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) { |