[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 5/6] RAFP: Coverity cleanup



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 <jferlan redhat com>
---
 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]