Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-1626

loadGrammar is releasing a DOMBuilder previously parsed document when it shouldn't

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.0
    • 2.8.0
    • None
    • Windows XP Pro 32bit,
      Xerces-2.7.0,
      Visual C++ 6.0 sp5

    Description

      I'm parsing xml file using Xerces-c 2.7 DOM.
      After loading a schema grammar to the parser, my previously parsed xml document is released (and therefore further access to the document in the code causes segmentation fault)

      I do the following things (more or less):

      1. create a XMLGrammarPoolImpl object and then create a new
      DOMBuilder using it as an input.

      m_grammarPool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);
      const XMLCh gLS[] =

      { chLatin_L, chLatin_S, chNull }

      ;
      m_DomImpl = DOMImplementationRegistry::getDOMImplementation(gLS);
      m_DomParser = ((DOMImplementationLS*)m_DomImpl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0, XMLPlatformUtils::fgMemoryManager, m_grammarPool);
      m_DomParser->setFeature(XMLUni::fgDOMNamespaces, true);
      m_DomParser->setFeature(XMLUni::fgXercesSchema, true);
      m_DomParser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
      m_DomParser->setFeature(XMLUni::fgDOMValidateIfSchema, true);
      m_DomParser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);

      2. Parse an xml file using the DOMBuilder and keep a reference to
      the DOMDocument, 'doc'

      doc = m_DomParser->parse(inputSource);

      3. Create a new DOMInputSource and call DOMBuilder
      ->loadGrammar(inputSrc, SchemaGrammarType, true)

      SchemaGrammar pGrammar = (SchemaGrammar) m_DomParser->loadGrammar(schemaInputSource, Grammar::SchemaGrammarType, true);

      The result is that my previous parsed document, 'doc' is being released by the following code in parsers\DOMBuilderImpl.cpp on DOMBuilderImpl::loadGrammar (line 703):

      // Release DOM tree - DTD

      DOMDocument* doc = adoptDocument();

      if (doc)

      doc->release();

      Attachments

        Activity

          People

            Unassigned Unassigned
            orid-sv Ori D.
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: