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

John Ferlan jferlan at redhat.com
Mon Apr 10 17:56:12 UTC 2017


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

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 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




More information about the libvir-list mailing list