Author: oshogbo
Date: Sun Jul 17 15:36:02 2016
New Revision: 302966
URL: https://svnweb.freebsd.org/changeset/base/302966

Log:
  Fix nvlist array memory leak.
  
  When we change nvl_array_next to NULL it means that we want to destroy or
  take nvlist_array. The nvpair, which stores next nvlist of nvlist_array 
element
  is no longer needed and can be freed.
  
  Submitted by: Adam Starak <starak.a...@gmail.com>
  MFC after:    1 week

Modified:
  head/sys/contrib/libnv/nvlist.c

Modified: head/sys/contrib/libnv/nvlist.c
==============================================================================
--- head/sys/contrib/libnv/nvlist.c     Sun Jul 17 15:29:31 2016        
(r302965)
+++ head/sys/contrib/libnv/nvlist.c     Sun Jul 17 15:36:02 2016        
(r302966)
@@ -236,10 +236,12 @@ nvlist_set_array_next(nvlist_t *nvl, nvp
 
        NVLIST_ASSERT(nvl);
 
-       if (ele != NULL)
+       if (ele != NULL) {
                nvl->nvl_flags |= NV_FLAG_IN_ARRAY;
-       else
+       } else {
                nvl->nvl_flags &= ~NV_FLAG_IN_ARRAY;
+               nv_free(nvl->nvl_array_next);
+       }
 
        nvl->nvl_array_next = ele;
 }
_______________________________________________
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