]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
libnv: fix memory leaks
authorMariusz Zaborski <oshogbo@FreeBSD.org>
Sun, 10 Feb 2019 23:28:55 +0000 (23:28 +0000)
committerMariusz Zaborski <oshogbo@FreeBSD.org>
Tue, 6 Jul 2021 17:58:08 +0000 (19:58 +0200)
commitdc876a5bcd46b486103c9127f51e01663504195b
tree633bea18d41ba7f77cfbc26c95c71ee806efb1da
parentb7c17fd730ca4e8806a506b617ad32218aa0b826
libnv: fix memory leaks

nvpair_create_stringv: free the temporary string; this fix affects
nvlist_add_stringf() and nvlist_add_stringv().

nvpair_remove_nvlist_array (NV_TYPE_NVLIST_ARRAY case): free the chain
of nvpairs (as resetting it prevents nvlist_destroy() from freeing it).
Note: freeing the chain in nvlist_destroy() is not sufficient, because
it would still leak through nvlist_take_nvlist_array().  This affects
all nvlist_*_nvlist_array() use

Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
Reported by: clang/gcc ASAN
MFC after: 2 weeks

(cherry picked from commit b5d787d93b3d83f28e87e1f8cc740cb160f8f0ac)
lib/libnv/tests/nvlist_send_recv_test.c
sys/contrib/libnv/nv_impl.h
sys/contrib/libnv/nvlist.c
sys/contrib/libnv/nvpair.c