We have to free def here, rather than after "cleanup:",
because "cleanup:" is on the successful-return path.
From 2c7800c3560f03fd77e4a458cb0e557165faed3f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 15 Feb 2010 17:54:15 +0100
Subject: [PATCH] vbox_tmpl.c: avoid leak on OOM error path
* src/vbox/vbox_tmpl.c (vboxDomainDumpXML): Free def upon virAsprintf
failure.
---
src/vbox/vbox_tmpl.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 68dffd2..1fb8d56 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -6059,14 +6059,15 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags
ATTRIBUTE_UNUSE
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
goto cleanup;
}
if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s",
network->name) < 0) {
virReportOOMError();
+ VIR_FREE(def);
goto cleanup;
}
PRUnichar *networkInterfaceNameUtf16 = NULL;
IHostNetworkInterface *networkInterface = NULL;
VBOX_UTF8_TO_UTF16(network->name, &networkInterfaceNameUtf16);
--
1.7.0.181.g41533