svn commit: r301596 - head/lib/libc/gen

Don Lewis truckman at FreeBSD.org
Wed Jun 8 10:25:18 UTC 2016


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) {


More information about the svn-src-all mailing list