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

[libvirt] [PATCH 25/26] qemu: Resolve Coverity NEGATIVE_RETURNS



Coverity notes that if the virConnectListAllDomains returns a negative
value then the loop at the cleanup label that ends on numDomains will
have issues.

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/qemu/qemu_driver.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 373b4d7..5ceed92 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1004,9 +1004,11 @@ qemuStateStop(void)
             ret = -1;
 
  cleanup:
-    for (i = 0; i < numDomains; i++)
-        virDomainFree(domains[i]);
-    VIR_FREE(domains);
+    if (domains) {
+        for (i = 0; i < numDomains; i++)
+            virDomainFree(domains[i]);
+        VIR_FREE(domains);
+    }
     VIR_FREE(flags);
     virObjectUnref(conn);
     virObjectUnref(cfg);
-- 
1.9.3


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