A new version of Coverity found:
filter_by_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 <[email protected]>
---
src/Virt_ResourceAllocationFromPool.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/Virt_ResourceAllocationFromPool.c
b/src/Virt_ResourceAllocationFromPool.c
index 7088900..7bee729 100644
--- a/src/Virt_ResourceAllocationFromPool.c
+++ b/src/Virt_ResourceAllocationFromPool.c
@@ -120,9 +120,12 @@ static int filter_by_pool(struct inst_list *dest,
poolid = pool_member_of(_BROKER, CLASSNAME(op), type, rasd_id);
if ((poolid != NULL) && STREQ(poolid, _poolid))
inst_list_add(dest, inst);
- }
- free(poolid);
+ if (poolid != NULL) {
+ free(poolid);
+ poolid = NULL;
+ }
+ }
return dest->cur;
}
--
1.8.4.2
_______________________________________________
Libvirt-cim mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvirt-cim