Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/conf/virnetworkobj.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index ed1f02f4c5..fd4bf779b9 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -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);
--
2.21.0