Re: [xml] xmlTextReaderClose causing segfault

On Sat, Apr 17, 2004 at 11:39:50AM -0400, Rob Richards wrote:
I have gone through with a debugger and even tried dumbing it way down. Its only when I try to use 
xmlTextReaderClose that the problem happens as that is one of the 2 places (other than xmlFreeTextReader) 
where xmlFreeParserCtxt is called. Once I make the call to xmlTextReaderClose, the final call to 
xmlFreeTextReader segfaults (actually in xmlTextReaderFreeDoc) as the first test for the context in 
xmlFreeTextReader is:
if (reader->ctxt != NULL) { // Here it is not NULL but has already been freed so it's garabge).

  yes, that's a bug. xmlTextReaderClose() should set up 
reader->ctxt to NULL after calling xmlFreeParserCtxt(), definitely.
I fixed my CVs checkount, I will commit this later.
Now the ways to turn around the problem is to allocate the context
yourself and use xmlReaderNewxxx instead of xmlReaderForxxx
that way libxml2 should not free the parser contect on Close, 
but you will have to do it, that should work.

  thanks for raising the issue,


Daniel Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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