[PATCH v2 3/4] conf: fix NULL deref when exporting ports

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux