From 52ae076a941b04f4196fe37c4972a783c2120112 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Fri, 23 Apr 2010 11:59:39 -0400 Subject: [PATCH] Fix memory leak in virsh snapshot-list. We were forgetting to release the memory allocated by virDomainSnapshotListNames. Free the memory properly. Signed-off-by: Chris Lalancette --- tools/virsh.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/virsh.c b/tools/virsh.c index b2a1538b80..5bcf0ede9a 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -8360,7 +8360,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; @@ -8447,6 +8447,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);