Re: [xslt] Leaking from extension function
- From: Daniel Veillard <veillard redhat com>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: Re: [xslt] Leaking from extension function
- Date: Thu, 17 Sep 2009 15:42:49 +0200
On Tue, Jul 07, 2009 at 10:37:46AM +0100, Tony Graham wrote:
> The function is currently leaking the xmlNode created from
> '<hello-world/>'. The leak occurs with various libxslt versions,
> including the latest SVN checkout.
[...]
> xmlDocPtr container = xsltCreateRVT (tctxt);
> if (container != NULL)
> {
> xsltRegisterLocalRVT (tctxt,
> container);
> ret = xmlXPathNewNodeSet (NULL);
> if (ret != NULL)
> {
> xmlNodePtr new_node = xmlDocCopyNodeList (container,
> doc->children);
> while (new_node != NULL)
> {
> xmlXPathNodeSetAdd (ret->nodesetval,
> new_node);
> new_node = new_node->next;
> }
> /*
> * Mark it as a function result in order to avoid garbage
> * collecting of tree fragments
> */
> xsltExtensionInstructionResultRegister(tctxt,
> ret);
> }
> }
> }
the new_nodes are inserted in the nodeset but never actually attached
to the container , so when it goes out of scope, the container is freed
but since your copied nodes were not attached to it they are still
leaked.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel veillard com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]