]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh-domain: Fix memleak in cmdUndefine with storage
authorPeter Krempa <pkrempa@redhat.com>
Mon, 12 Aug 2013 14:09:53 +0000 (16:09 +0200)
committerJán Tomko <jtomko@redhat.com>
Fri, 16 Aug 2013 18:41:10 +0000 (20:41 +0200)
When undefining a domain with storage when the volume isn't managed by
libvirt the name and path strings weren't freed properly.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=996050
(cherry picked from commit 5075248ac9e60dd73da3487f83be9aa188200688)

tools/virsh-domain.c

index 8cafce4ccc9c268fd8d1aac0b0c5a0f5e3e9dbb7..57065e48efb0b7fb6f89f356a70a7e75cd3523ff 100644 (file)
@@ -3048,6 +3048,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
 
         for (i = 0; i < nvolumes; i++) {
             ctxt->node = vol_nodes[i];
+            VIR_FREE(source);
+            VIR_FREE(target);
 
             /* get volume source and target paths */
             if (!(target = virXPathString("string(./target/@dev)", ctxt)))
@@ -3090,6 +3092,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
             }
             vlist[nvols].source = source;
             vlist[nvols].target = target;
+            source = NULL;
+            target = NULL;
             nvols++;
         }
 
@@ -3189,6 +3193,8 @@ out:
     }
 
 cleanup:
+    VIR_FREE(source);
+    VIR_FREE(target);
     for (i = 0; i < nvols; i++) {
         VIR_FREE(vlist[i].source);
         VIR_FREE(vlist[i].target);