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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]