conf: Fix virNodeDeviceObjGetNames nnames increment

To be safer, only increment nnames after the VIR_STRDUP is successful.
This commit is contained in:
John Ferlan 2017-04-10 08:33:08 -04:00
parent fd6e3f48ed
commit 44d3db9785

View File

@ -512,10 +512,11 @@ virNodeDeviceObjGetNames(virNodeDeviceObjListPtr devs,
virNodeDeviceObjLock(obj); virNodeDeviceObjLock(obj);
if (aclfilter && aclfilter(conn, obj->def) && if (aclfilter && aclfilter(conn, obj->def) &&
(!cap || virNodeDeviceObjHasCap(obj, cap))) { (!cap || virNodeDeviceObjHasCap(obj, cap))) {
if (VIR_STRDUP(names[nnames++], obj->def->name) < 0) { if (VIR_STRDUP(names[nnames], obj->def->name) < 0) {
virNodeDeviceObjUnlock(obj); virNodeDeviceObjUnlock(obj);
goto failure; goto failure;
} }
nnames++;
} }
virNodeDeviceObjUnlock(obj); virNodeDeviceObjUnlock(obj);
} }