conf: fix g_new0 allocation

Fixes commit <a5d88ffe0ad9b5d5314ab0058c5b363f9f79b8ee> which changed
allocation from VIR_ALLOC_N to g_new0 but missed some +1 on number of
allocated elements.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Pavel Hrdina 2020-10-12 19:45:37 +02:00
parent accdc0e773
commit 8a666dccda
3 changed files with 4 additions and 4 deletions

View File

@ -320,7 +320,7 @@ virInterfaceObjListExport(virConnectPtr conn,
virObjectRWLockRead(ifaceobjs);
if (ifaces)
data.ifaces = g_new0(virInterfacePtr, virHashSize(ifaceobjs->objsName));
data.ifaces = g_new0(virInterfacePtr, virHashSize(ifaceobjs->objsName) + 1);
virHashForEach(ifaceobjs->objsName, virInterfaceObjListExportCallback, &data);

View File

@ -1407,7 +1407,7 @@ virNetworkObjListExport(virConnectPtr conn,
virObjectRWLockRead(netobjs);
if (nets)
data.nets = g_new0(virNetworkPtr, virHashSize(netobjs->objs));
data.nets = g_new0(virNetworkPtr, virHashSize(netobjs->objs) + 1);
virHashForEach(netobjs->objs, virNetworkObjListExportCallback, &data);
@ -1801,7 +1801,7 @@ virNetworkObjPortListExport(virNetworkPtr net,
if (ports) {
*ports = NULL;
data.ports = g_new0(virNetworkPortPtr, virHashSize(obj->ports));
data.ports = g_new0(virNetworkPortPtr, virHashSize(obj->ports) + 1);
}
virHashForEach(obj->ports, virNetworkObjPortListExportCallback, &data);

View File

@ -931,7 +931,7 @@ virNodeDeviceObjListExport(virConnectPtr conn,
virObjectRWLockRead(devs);
if (devices)
data.devices = g_new0(virNodeDevicePtr, virHashSize(devs->objs));
data.devices = g_new0(virNodeDevicePtr, virHashSize(devs->objs) + 1);
virHashForEach(devs->objs, virNodeDeviceObjListExportCallback, &data);
virObjectRWUnlock(devs);