aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Krempa <pkrempa@redhat.com>2012-09-19 11:31:44 +0200
committerPeter Krempa <pkrempa@redhat.com>2012-09-19 14:44:42 +0200
commit1035c51f3bbea9e6d9fdaacfa3863c5a525cd3b0 (patch)
treebc651f512457c5fac83014213be89db3a0310086
parentutil: don't print free'd dmidecode path (diff)
downloadlibvirt-1035c51f3bbea9e6d9fdaacfa3863c5a525cd3b0.tar.gz
libvirt-1035c51f3bbea9e6d9fdaacfa3863c5a525cd3b0.tar.bz2
libvirt-1035c51f3bbea9e6d9fdaacfa3863c5a525cd3b0.zip
virsh: Fix resource leaks when editing files.
The cleanup path in virsh-edit helper was never reached when the edit was successful leaking the document in memory as well as the temporary file.
-rw-r--r--tools/virsh-edit.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c
index 512ac0d86..0ed0e8f0c 100644
--- a/tools/virsh-edit.c
+++ b/tools/virsh-edit.c
@@ -68,6 +68,7 @@ do {
char *doc_edited = NULL;
char *doc_reread = NULL;
const char *msg = NULL;
+ bool edit_success = false;
/* Get the XML configuration of the object. */
doc = (EDIT_GET_XML);
@@ -139,7 +140,7 @@ redefine:
}
}
- break;
+ edit_success = true;
edit_cleanup:
VIR_FREE(doc);
@@ -149,7 +150,9 @@ edit_cleanup:
unlink (tmp);
VIR_FREE(tmp);
}
- goto cleanup;
+
+ if (!edit_success)
+ goto cleanup;
} while (0);