From: Daniel P. Berrangé Date: Tue, 18 Jun 2019 17:33:04 +0000 (+0100) Subject: conf: fix NULL deref when exporting ports X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=520f5752bece34af717303161ea01715c0ec21ce;p=libvirt.git conf: fix NULL deref when exporting ports Reviewed-by: John Ferlan Signed-off-by: Daniel P. Berrangé --- diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index adf144fae2..12cefebaa8 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);