Author: truckman
Date: Wed Jun 15 06:42:30 2016
New Revision: 301921
URL: https://svnweb.freebsd.org/changeset/base/301921

Log:
  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

Modified:
  stable/10/lib/libc/gen/getnetgrent.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/gen/getnetgrent.c
==============================================================================
--- stable/10/lib/libc/gen/getnetgrent.c        Wed Jun 15 06:40:30 2016        
(r301920)
+++ stable/10/lib/libc/gen/getnetgrent.c        Wed Jun 15 06:42:30 2016        
(r301921)
@@ -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) {
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to