Re: [xml] Memory leak in xmlSAXParseMemory



On Mon, Nov 11, 2002 at 08:42:29PM -0800, Peter Jones wrote:
I found a small memory leak in xmlSAXParseMemory. It calls
xmlCreateMemoryParserCtxt, which calls xmlNewParserCtxt, which then
calls xmlInitParserCtxt, which finally calls xmlMalloc for a new
xmlSAXHandler.

If a xmlSAXHandler pointer is given to xmlSAXParseMemory, the one
allocated in xmlInitParserCtxt will be leaked. The attached patch
(ctxt-sax.patch) contains a fix.

  Hum, okay, a long time ago the sax field was filled with a reference
with the default SAX table instead of a copy, that may explain how this
leak appeared.

I also noticed that there is no xmlSAXParseMemoryWithData function. The
second attached patch (withdata.patch) implements one and changes
xmlSAXParseMemory so that it is implemented in terms of
xmlSAXParseMemoryWithData.

  Okay, applied too,

    thanks,

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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