[libvirt] [libvirt PATCH v6 09/15] xen_common: Adapt xenParseEmulatedDevices due to changes in xenConfigGetString

Fabiano Fidêncio fidencio at redhat.com
Tue Sep 18 18:48:12 UTC 2018


xenConfigGetString returns a newly-allocated pointer and it has to be
freed by the caller.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 src/xenconfig/xen_common.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index f787827008..5d88577222 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -1060,17 +1060,22 @@ static int
 xenParseEmulatedDevices(virConfPtr conf, virDomainDefPtr def)
 {
     const char *str;
+    int ret = -1;
 
     if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (xenConfigGetString(conf, "soundhw", &str, NULL) < 0)
-            return -1;
+            goto cleanup;
 
         if (str &&
             xenParseSxprSound(def, str) < 0)
-            return -1;
+            goto cleanup;
     }
 
-    return 0;
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(str);
+    return ret;
 }
 
 
-- 
2.17.1




More information about the libvir-list mailing list