From: Roland Schulz Date: Wed, 23 May 2018 12:40:41 +0000 (+0200) Subject: Fix memory leak issues in virshAllocpagesPagesizeCompleter. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0babf84797a070b5db84644bea637e62cd94d892;p=libvirt.git Fix memory leak issues in virshAllocpagesPagesizeCompleter. Signed-off-by: Roland Schulz Signed-off-by: Michal Privoznik --- diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 1435d1d4c6..cbd5326d0f 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))) 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;