conf: fix NULL deref when exporting ports

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2019-06-18 18:33:04 +01:00
parent cce545ddb6
commit 520f5752be

View File

@ -1810,10 +1810,12 @@ virNetworkObjPortListExport(virNetworkPtr net,
};
int ret = -1;
*ports = NULL;
if (ports) {
*ports = NULL;
if (ports && VIR_ALLOC_N(data.ports, virHashSize(obj->ports) + 1) < 0)
goto cleanup;
if (VIR_ALLOC_N(data.ports, virHashSize(obj->ports) + 1) < 0)
goto cleanup;
}
virHashForEach(obj->ports, virNetworkObjPortListExportCallback, &data);