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