[PATCH v2 4/7] virsh-interface: Resolve Coverity issues

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

 



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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 9fdd36e..0f78551 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -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);
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]