From 520f5752bece34af717303161ea01715c0ec21ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Tue, 18 Jun 2019 18:33:04 +0100 Subject: [PATCH] conf: fix NULL deref when exporting ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: John Ferlan Signed-off-by: Daniel P. Berrangé --- 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 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); -- GitLab