]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh-interface: Resolve Coverity issues
authorJohn Ferlan <jferlan@redhat.com>
Thu, 11 Jul 2013 14:31:15 +0000 (10:31 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 11 Jul 2013 18:18:11 +0000 (14:18 -0400)
Recent changes uncovered FORWARD_NULL and NEGATIVE_RETURNS problems with
the processing of the 'nActiveIfaces' and 'nInactiveIfaces' and their
associated allocated arrays in 'vshInterfaceListCollect' due to the
possibility of returning -1 in a call and using the return value as a
for loop index end condition.

tools/virsh-interface.c

index 9fdd36e6e67615108b63e026d2c4c24958863c9c..0f78551043498b272b0e67615f47c7aac3406f51 100644 (file)
@@ -300,10 +300,10 @@ finished:
     success = true;
 
 cleanup:
-    for (i = 0; i < nActiveIfaces; i++)
+    for (i = 0; nActiveIfaces != -1 && i < nActiveIfaces; i++)
         VIR_FREE(activeNames[i]);
 
-    for (i = 0; i < nInactiveIfaces; i++)
+    for (i = 0; nInactiveIfaces != -1 && i < nInactiveIfaces; i++)
         VIR_FREE(inactiveNames[i]);
 
     VIR_FREE(activeNames);