Re: [xml] memory leak while parsing from memory buffer



Daniel Veillard <veillard redhat com> writes:

On Wed, Apr 07, 2004 at 07:48:49PM +0200, Petr Pajas wrote:
But, although ctxt->input->filename _does_ get freed with
xmlFreeParserCtxt, the above code leaks. If the line with xmlStrdup is
removed, the leak disappears. I suspect, that somewhere, during
xmlParseDocument some copies of filename are made but never freed or
something similar. Otherwise I don't know why this line would make any
difference. BTW, it's the same if I set

ctxt->input->filename = "";

and put 

ctxt->input->filename = NULL;

just before xmlFreeParserCtxt(ctxt).

Any hints?

  that would mean that the error handling code leaks.

Not necessarily. I didn't express myself well. The leak appears even
when parsing a well-formed XML string and validation off. I mentioned
the errors just to advocate for assigning to ctxt->input->filename.

For some reasons it doesn't seems to occur in the common path
of libxml2, even when trying to reproduce exactly the same prob
with a libxml2 compiled with memory debug (xmlsoft.org/memory.html):

paphio:~/XML -> xmllint --memory --valid --noout tst.xml
tst.xml:4: element bar: validity error : No declaration for element bar
<bar/>
      ^

Hm, looking into xmllint.c and parser.c it really looks very much same
to our case. I'll try to craft a test script in C and see. 

Thanks, 

-- Petr

Attachment: pgpxs5vGeqRPC.pgp
Description: PGP signature



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