43fe83
From c19ba72c3346f46ba9cd59e573d87aa854869798 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <c19ba72c3346f46ba9cd59e573d87aa854869798.1377873640.git.jdenemar@redhat.com>
43fe83
From: Peter Krempa <pkrempa@redhat.com>
43fe83
Date: Wed, 21 Aug 2013 12:43:29 +0200
43fe83
Subject: [PATCH] virsh-domain: Fix memleak in cmdUndefine with storage
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=999057 [7.0]
43fe83
43fe83
When undefining a domain with storage when the volume isn't managed by
43fe83
libvirt the name and path strings weren't freed properly.
43fe83
43fe83
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=996050 [6.6]
43fe83
(cherry picked from commit 5075248ac9e60dd73da3487f83be9aa188200688)
43fe83
---
43fe83
 tools/virsh-domain.c | 6 ++++++
43fe83
 1 file changed, 6 insertions(+)
43fe83
43fe83
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
43fe83
index 2134e57..e2e4409 100644
43fe83
--- a/tools/virsh-domain.c
43fe83
+++ b/tools/virsh-domain.c
43fe83
@@ -3048,6 +3048,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
43fe83
 
43fe83
         for (i = 0; i < nvolumes; i++) {
43fe83
             ctxt->node = vol_nodes[i];
43fe83
+            VIR_FREE(source);
43fe83
+            VIR_FREE(target);
43fe83
 
43fe83
             /* get volume source and target paths */
43fe83
             if (!(target = virXPathString("string(./target/@dev)", ctxt)))
43fe83
@@ -3090,6 +3092,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
43fe83
             }
43fe83
             vlist[nvols].source = source;
43fe83
             vlist[nvols].target = target;
43fe83
+            source = NULL;
43fe83
+            target = NULL;
43fe83
             nvols++;
43fe83
         }
43fe83
 
43fe83
@@ -3189,6 +3193,8 @@ out:
43fe83
     }
43fe83
 
43fe83
 cleanup:
43fe83
+    VIR_FREE(source);
43fe83
+    VIR_FREE(target);
43fe83
     for (i = 0; i < nvols; i++) {
43fe83
         VIR_FREE(vlist[i].source);
43fe83
         VIR_FREE(vlist[i].target);
43fe83
-- 
43fe83
1.8.3.2
43fe83