[PATCH] vbox_network: fix possible memory leak in vboxNetworkDefineCreateXML()

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

 



virNetworkDef was not freed if the function failed in the first
two ifs, causing a possible memory leak.

Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 src/vbox/vbox_network.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c
index afd2acbb03..d97f571d1b 100644
--- a/src/vbox/vbox_network.c
+++ b/src/vbox/vbox_network.c
@@ -375,7 +375,7 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start)
     PRUnichar *networkNameUtf16 = NULL;
     char *networkNameUtf8 = NULL;
     IHostNetworkInterface *networkInterface = NULL;
-    virNetworkDef *def = virNetworkDefParseString(xml, NULL);
+    virNetworkDef *def = NULL;
     virNetworkIPDef *ipdef = NULL;
     unsigned char uuid[VIR_UUID_BUFLEN];
     vboxIID vboxnetiid;
@@ -394,7 +394,7 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start)
 
     VBOX_IID_INITIALIZE(&vboxnetiid);
 
-    if ((!def) ||
+    if (!(def = virNetworkDefParseString(xml, NULL)) ||
         (def->forward.type != VIR_NETWORK_FORWARD_NONE) ||
         (def->nips == 0 || !def->ips))
         goto cleanup;
-- 
2.31.1




[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