[PATCH] Fix memory leak issues in virshAllocpagesPagesizeCompleter.

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

 



Signed-off-by: Roland Schulz <schullzroll@xxxxxxxxx>
---
 tools/virsh-completer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index 1435d1d4c..c72f3bcad 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -576,6 +576,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
     virshControlPtr priv = ctl->privData;
     unsigned int npages = 0;
     xmlNodePtr *pages = NULL;
+    xmlDocPtr doc = NULL;
     double size = 0;
     size_t i = 0;
     const char *suffix = NULL;
@@ -595,7 +596,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
     if (!(cap_xml = virConnectGetCapabilities(priv->conn)))
         goto error;
 
-    if (!(virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)))
+    if ((doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)) == NULL)
         goto error;
 
     if (cellno && vshCommandOptStringQuiet(ctl, cmd, "cellno", &cellnum) > 0) {
@@ -631,12 +632,11 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
 
  cleanup:
     xmlXPathFreeContext(ctxt);
-    for (i = 0; i < npages; i++)
-        VIR_FREE(pages[i]);
     VIR_FREE(pages);
-    VIR_FREE(cap_xml);
+    xmlFreeDoc(doc);
     VIR_FREE(path);
     VIR_FREE(pagesize);
+    VIR_FREE(cap_xml);
     VIR_FREE(unit);
 
     return ret;
-- 
2.17.0

--
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]

  Powered by Linux