]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Fix virNodeDeviceObjGetNames nnames increment
authorJohn Ferlan <jferlan@redhat.com>
Mon, 10 Apr 2017 12:33:08 +0000 (08:33 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 10 Apr 2017 17:47:02 +0000 (13:47 -0400)
To be safer, only increment nnames after the VIR_STRDUP is successful.

src/conf/virnodedeviceobj.c

index 53df1b834e91397b5d69cd4bdd738058189341ca..75ba1a02da7b5d50615347595638571a28a2ea53 100644 (file)
@@ -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);
     }