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

tools/virsh-nodedev.c

index 2eb197985d825a64ff09930fb0455df4b7c2f7a4..32550796ce31490f0d54b042d72c32a1703206db 100644 (file)
@@ -352,7 +352,7 @@ finished:
     success = true;
 
 cleanup:
-    for (i = 0; i < ndevices; i++)
+    for (i = 0; ndevices != -1 && i < ndevices; i++)
         VIR_FREE(names[i]);
     VIR_FREE(names);