[PATCH 1/2] conf: Fix virNodeDeviceObjGetNames nnames increment

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

 



To be safer, only increment nnames after the VIR_STRDUP is successful.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/virnodedeviceobj.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 53df1b8..75ba1a0 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -512,10 +512,11 @@ virNodeDeviceObjGetNames(virNodeDeviceObjListPtr devs,
         virNodeDeviceObjLock(obj);
         if (aclfilter && aclfilter(conn, obj->def) &&
             (!cap || virNodeDeviceObjHasCap(obj, cap))) {
-            if (VIR_STRDUP(names[nnames++], obj->def->name) < 0) {
+            if (VIR_STRDUP(names[nnames], obj->def->name) < 0) {
                 virNodeDeviceObjUnlock(obj);
                 goto failure;
             }
+            nnames++;
         }
         virNodeDeviceObjUnlock(obj);
     }
-- 
2.9.3

--
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]
  Powered by Linux