]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
virsh: edit: don't leak XML string on reedit or redefine
authorJán Tomko <jtomko@redhat.com>
Tue, 25 Jun 2013 13:10:27 +0000 (15:10 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 25 Jun 2013 13:37:20 +0000 (15:37 +0200)
Free the old XML strings before overwriting them if the user
has chosen to reedit the file or force the redefinition.

Found by Alex Jia trying to reproduce another bug:
https://bugzilla.redhat.com/show_bug.cgi?id=977430#c3

tools/virsh-edit.c

index 9d612a3e3ba3d3f2c49317f2c1ddac29163ce114..bb79853e086906562a0717f6afbd9dd2caa8a5ce 100644 (file)
@@ -86,6 +86,7 @@ reedit:
         goto edit_cleanup;
 
     /* Read back the edited file. */
+    VIR_FREE(doc_edited);
     doc_edited = vshEditReadBackFile(ctl, tmp);
     if (!doc_edited)
         goto edit_cleanup;
@@ -102,6 +103,7 @@ redefine:
      * it was being edited?  This also catches problems such as us
      * losing a connection or the object going away.
      */
+    VIR_FREE(doc_reread);
     doc_reread = (EDIT_GET_XML);
     if (!doc_reread)
         goto edit_cleanup;