virNetworkDef was not freed if the function failed in the first
two ifs, causing a possible memory leak.
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
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