Author: delphij
Date: Fri Jun 30 07:04:10 2017
New Revision: 320494
URL: https://svnweb.freebsd.org/changeset/base/320494

Log:
  Revert r300385 and r300624 which was false positive
  reported by cppcheck.
  
  dup_ncp() tries to allocate a buffer of MAXNETCONFIGLINE
  as tmp, which is then assigned to p->nc_netid via strcpy,
  so the free(p->nc_netid) would have correctly released
  the memory in case nc_lookups() fails, therefore, the
  allerged leak never existed.
  
  MFC after:    3 days

Modified:
  head/lib/libc/rpc/getnetconfig.c

Modified: head/lib/libc/rpc/getnetconfig.c
==============================================================================
--- head/lib/libc/rpc/getnetconfig.c    Fri Jun 30 06:34:49 2017        
(r320493)
+++ head/lib/libc/rpc/getnetconfig.c    Fri Jun 30 07:04:10 2017        
(r320494)
@@ -692,7 +692,7 @@ static struct netconfig *
 dup_ncp(struct netconfig *ncp)
 {
     struct netconfig   *p;
-    char       *tmp, *tmp2;
+    char       *tmp;
     u_int      i;
 
     if ((tmp=malloc(MAXNETCONFIGLINE)) == NULL)
@@ -701,7 +701,6 @@ dup_ncp(struct netconfig *ncp)
        free(tmp);
        return(NULL);
     }
-    tmp2 = tmp;
     /*
      * First we dup all the data from matched netconfig buffer.  Then we
      * adjust some of the member pointer to a pre-allocated buffer where
@@ -723,7 +722,6 @@ dup_ncp(struct netconfig *ncp)
     if (p->nc_lookups == NULL) {
        free(p->nc_netid);
        free(p);
-       free(tmp2);
        return(NULL);
     }
     for (i=0; i < p->nc_nlookups; i++) {
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to