[libvirt] [PATCH 8/8] Fix memory leak in virsh snapshot-list.

Chris Lalancette clalance at redhat.com
Fri Apr 23 17:27:52 UTC 2010


We were forgetting to release the memory allocated by
virDomainSnapshotListNames.  Free the memory properly.

Signed-off-by: Chris Lalancette <clalance at redhat.com>
---
 tools/virsh.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 93a9f45..04b47a1 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8345,7 +8345,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
     int ret = FALSE;
     int numsnaps;
     char **names = NULL;
-    int actual;
+    int actual = 0;
     int i;
     xmlDocPtr xml = NULL;
     xmlXPathContextPtr ctxt = NULL;
@@ -8432,6 +8432,8 @@ cleanup:
     if (xml)
         xmlFreeDoc(xml);
     VIR_FREE(doc);
+    for (i = 0; i < actual; i++)
+        VIR_FREE(names[i]);
     VIR_FREE(names);
     if (dom)
         virDomainFree(dom);
-- 
1.6.6.1




More information about the libvir-list mailing list