svn commit: r303826 - stable/11/sys/contrib/libnv

Mariusz Zaborski oshogbo at FreeBSD.org
Mon Aug 8 06:33:59 UTC 2016


Author: oshogbo
Date: Mon Aug  8 06:33:57 2016
New Revision: 303826
URL: https://svnweb.freebsd.org/changeset/base/303826

Log:
  MFC r302966:
    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.adam at gmail.com>
    Approved by:	re (gjb)

Modified:
  stable/11/sys/contrib/libnv/nvlist.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/contrib/libnv/nvlist.c
==============================================================================
--- stable/11/sys/contrib/libnv/nvlist.c	Mon Aug  8 06:29:25 2016	(r303825)
+++ stable/11/sys/contrib/libnv/nvlist.c	Mon Aug  8 06:33:57 2016	(r303826)
@@ -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;
 }


More information about the svn-src-all mailing list