A new version of Coverity found:
get_dev_from_pool(): RESOURCE_LEAK
- Because the code is run within a for() loop Coverity complains
that the returned 'poolid' is not free'd during each pass through
the loop. So even though it may not be fetched again, just free()
and reinitialize 'poolid' after usage
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/Virt_ElementAllocatedFromPool.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/Virt_ElementAllocatedFromPool.c b/src/Virt_ElementAllocatedFromPool.c
index 03d856a..2c2f2d1 100644
--- a/src/Virt_ElementAllocatedFromPool.c
+++ b/src/Virt_ElementAllocatedFromPool.c
@@ -124,10 +124,14 @@ static CMPIStatus get_dev_from_pool(const CMPIObjectPath *ref,
poolid = pool_member_of(_BROKER, cn, type, dev_id);
if (poolid && STREQ(poolid, _poolid))
inst_list_add(list, inst);
+
+ if (poolid) {
+ free(poolid);
+ poolid = NULL;
+ }
}
out:
- free(poolid);
inst_list_free(&tmp);
return s;
--
1.8.4.2