Because nvp wasn't initialized on every loop iteration once we jumped
authoroshogbo <oshogbo@FreeBSD.org>
Thu, 21 Sep 2017 10:10:42 +0000 (10:10 +0000)
committeroshogbo <oshogbo@FreeBSD.org>
Thu, 21 Sep 2017 10:10:42 +0000 (10:10 +0000)
commitc8344b908199e4cfbf35569d5845c18a8c20e1e6
treee40e887dd6f32c3a36a75ae1a0c8d7265e74250b
parent9be4bc1273bef2f0ae95840b7190478a5d26bdf2
Because nvp wasn't initialized on every loop iteration once we jumped
to 'fail' on error it was treated as success, because nvp!=NULL. Fix this
by not handling success under 'fail' label and by using separate variable
for parent nvpair.

If we succeeded to allocate nvlist, but failed to allocated nvpair we
would leak nvls[ii] on return. Destroy it when we cannot allocate nvpair,
before we goto fail.

Submitted by: pjd@ and oshogbo@ (minor changes)
Found by:       scan-build
MFC after: 1 month
Sponsored by: Wheel Systems
sys/contrib/libnv/nvpair.c