[libvirt] [PATCH] Fix memory leaks in cmdInterfaceEdit and cmdNWFilterEdit.

This applies a fix to thos functions similar to that made to cmdEdit in 270895063d1cf86ab42fa220a8d090c24d58dbc0, thus fnixing a memory leak - if tmp is unlinked and NULLed early in the function, the memory used by tmp is never freed. Since we will always unlink tmp prior to freeing its memory at the end of the function, just remove the earlier code and let cleanup: do the cleanup. --- tools/virsh.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index eb11a78..fb66a72 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -3248,9 +3248,6 @@ cmdInterfaceEdit (vshControl *ctl, const vshCmd *cmd) doc_edited = editReadBackFile (ctl, tmp); if (!doc_edited) goto cleanup; - unlink (tmp); - tmp = NULL; - /* Compare original XML with edited. Has it changed at all? */ if (STREQ (doc, doc_edited)) { vshPrint (ctl, _("Interface %s XML configuration not changed.\n"), @@ -4193,9 +4190,6 @@ cmdNWFilterEdit (vshControl *ctl, const vshCmd *cmd) doc_edited = editReadBackFile (ctl, tmp); if (!doc_edited) goto cleanup; - unlink (tmp); - tmp = NULL; - /* Compare original XML with edited. Has it changed at all? */ if (STREQ (doc, doc_edited)) { vshPrint (ctl, _("Network filter %s XML configuration not changed.\n"), -- 1.6.6.1

On 04/30/2010 10:20 PM, Laine Stump wrote:
This applies a fix to thos functions similar to that made to cmdEdit in 270895063d1cf86ab42fa220a8d090c24d58dbc0, thus fnixing a memory leak - if tmp is unlinked and NULLed early in the function, the memory used by tmp is never freed. Since we will always unlink tmp prior to freeing its memory at the end of the function, just remove the earlier code and let cleanup: do the cleanup.
ACK. Gotta love leak cleanups by code deletion. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Sat, May 01, 2010 at 12:20:34AM -0400, Laine Stump wrote:
This applies a fix to thos functions similar to that made to cmdEdit in 270895063d1cf86ab42fa220a8d090c24d58dbc0, thus fnixing a memory leak - if tmp is unlinked and NULLed early in the function, the memory used by tmp is never freed. Since we will always unlink tmp prior to freeing its memory at the end of the function, just remove the earlier code and let cleanup: do the cleanup.
ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Daniel Veillard
-
Eric Blake
-
Laine Stump