mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
conf: Fix virNodeDeviceObjGetNames nnames increment
To be safer, only increment nnames after the VIR_STRDUP is successful.
This commit is contained in:
parent
fd6e3f48ed
commit
44d3db9785
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user