[libvirt] [PATCH] Fix memory leak in cmdAttachDisk

hwbi hwbi2008 at gmail.com
Sat Aug 31 03:39:35 UTC 2013


When virBufferError is ok in cmdAttachDisk,the latter
should 'goto cleanup',instead of returning a false to
prevent memory leaking.
---
 tools/virsh-domain.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 3fd57fd..568d61d 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -661,7 +661,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
 
     if (virBufferError(&buf)) {
         vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
-        return false;
+        goto cleanup;
     }
 
     xml = virBufferContentAndReset(&buf);
-- 
1.7.1




More information about the libvir-list mailing list