Date: Wed, 8 Jun 2016 10:25:16 +0000 (UTC) From: Don Lewis <truckman@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301596 - head/lib/libc/gen Message-ID: <201606081025.u58APGgG070427@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: truckman Date: Wed Jun 8 10:25:16 2016 New Revision: 301596 URL: https://svnweb.freebsd.org/changeset/base/301596 Log: 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 Modified: head/lib/libc/gen/getnetgrent.c Modified: head/lib/libc/gen/getnetgrent.c ============================================================================== --- head/lib/libc/gen/getnetgrent.c Wed Jun 8 10:00:43 2016 (r301595) +++ head/lib/libc/gen/getnetgrent.c Wed Jun 8 10:25:16 2016 (r301596) @@ -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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606081025.u58APGgG070427>