[libvirt] [PATCH] 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. --- tools/virsh-edit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c index 512ac0d..0ed0e8f 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); -- 1.7.12

On 19.09.2012 11:43, Peter Krempa wrote:
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. --- tools/virsh-edit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
ACK Michal

On 09/19/12 14:42, Michal Privoznik wrote:
On 19.09.2012 11:43, Peter Krempa wrote:
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. --- tools/virsh-edit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
ACK
Michal
Pushed. Thanks! Peter
participants (2)
-
Michal Privoznik
-
Peter Krempa