]> 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)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 15 Aug 2013 14:47:49 +0000 (16:47 +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

tools/virsh-domain.c

index 3b2513b85a937d224153051a26c68c5fcf9f2df6..ab3804a144fd067123bec3c7ed6e35424fc4a151 100644 (file)
@@ -3052,6 +3052,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)))
@@ -3094,6 +3096,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
             }
             vlist[nvols].source = source;
             vlist[nvols].target = target;
+            source = NULL;
+            target = NULL;
             nvols++;
         }
 
@@ -3193,6 +3197,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);