summaryrefslogtreecommitdiffstats
path: root/sys/contrib
diff options
context:
space:
mode:
authoroshogbo <oshogbo@FreeBSD.org>2016-08-08 06:33:57 +0000
committeroshogbo <oshogbo@FreeBSD.org>2016-08-08 06:33:57 +0000
commitf3af2964a3b0e906db71eaa05653924efbbda00a (patch)
tree67cc292a00885014d9fd93dc4453c895bcb2ced0 /sys/contrib
parent9ebf0d4abe09912ceadc5551d5952540fb4fcfcf (diff)
downloadFreeBSD-src-f3af2964a3b0e906db71eaa05653924efbbda00a.zip
FreeBSD-src-f3af2964a3b0e906db71eaa05653924efbbda00a.tar.gz
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@gmail.com> Approved by: re (gjb)
Diffstat (limited to 'sys/contrib')
-rw-r--r--sys/contrib/libnv/nvlist.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/contrib/libnv/nvlist.c b/sys/contrib/libnv/nvlist.c
index cf8281e..4da294d 100644
--- a/sys/contrib/libnv/nvlist.c
+++ b/sys/contrib/libnv/nvlist.c
@@ -236,10 +236,12 @@ nvlist_set_array_next(nvlist_t *nvl, nvpair_t *ele)
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;
}
OpenPOWER on IntegriCloud