Re: [xml] segfault when calling xmlIOParseDTD



On Wed, Mar 10, 2004 at 04:50:16PM +0100, Tanguy Fautre wrote:
          NEXT;
          if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
              (ctxt->sax->elementDecl != NULL))
              ctxt->sax->elementDecl(ctxt->userData, name, ret,
                                     content);

the reason is that userData is NULL, and elementDecl is a pointer to 
xmlSAX2ElementDecl(), which expects a xmlParserCtxtPtr.

Because xmlIOParseDTD creates and handle its own xmlParserCtxt, I'm suspicious 
about the line 9954 in parser.c "ctxt->userData = NULL;" and it might have to 
be something like "ctxt->userData = ctxt;".

  Hum, you provided a SAX context, I bet your example would 
work if you passed NULL there. Since you pass the SAX block,
you're basically responsible for the behaviour of the routines
in that block in those conditions.
  Now whether ctxt->userData should be initialized to ctxt
my answer would be "why not" since the APIs don't allow to pass
an user data, so it's better to have something meaningful for the
default routines there.
  So I somewhat disagree with the bug being really libxml2 fault,
but also somewhat agree with the potential fix. I made the change
in CVS, since I don't think this can impact negatively existing
users of the API :-)

  thanks for the report, but I have a hard time digesting C++ ;-)

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]