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

memory leak in reading XMLURL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.0, 2.6.0
    • 2.7.0
    • Utilities
    • None
    • redhat linux AS3.0,
      bash-2.05b$ uname -a
      Linux 2.4.21-15 #1 Wed May 12 13:47:22 EDT 2004 i686 i686 i386 GNU/Linux

    Description

      #include <stdio.h>
      #include <string>
      #include <iostream>
      #include <xercesc/util/PlatformUtils.hpp>
      #include <xercesc/parsers/AbstractDOMParser.hpp>
      #include <xercesc/dom/DOMImplementation.hpp>
      #include <xercesc/dom/DOMImplementationLS.hpp>
      #include <xercesc/dom/DOMImplementationRegistry.hpp>
      #include <xercesc/dom/DOMBuilder.hpp>
      #include <xercesc/dom/DOMException.hpp>
      #include <xercesc/dom/DOMDocument.hpp>
      #include <xercesc/dom/DOMNodeList.hpp>
      #include <xercesc/dom/DOMError.hpp>
      #include <xercesc/dom/DOMLocator.hpp>
      #include <xercesc/dom/DOMNamedNodeMap.hpp>
      #include <xercesc/dom/DOMAttr.hpp>
      #include <xercesc/framework/MemBufInputSource.hpp>

      #ifdef XERCES_CPP_NAMESPACE_USE
      XERCES_CPP_NAMESPACE_USE
      #endif

      int read_url(std::string const & url_str){
      int rc = 0;
      xercesc::XercesDOMParser * parser;
      xercesc::DOMDocument *m_pDoc;

      bool bRecognizeNEL;

      xercesc::AbstractDOMParser::ValSchemes valScheme;
      bool bDoNamespaces;
      bool bDoSchema;
      bool bSchemaFullChecking;
      bool bDatatypeNormalization;
      bool bCreateEntityReferenceNodes;

      bRecognizeNEL = false;

      valScheme = AbstractDOMParser::Val_Auto;
      bDoNamespaces = false;
      bDoSchema = false;
      bSchemaFullChecking = false;
      bCreateEntityReferenceNodes = false;
      bDatatypeNormalization = true;

      // Initialize the XML4C system
      try

      { XMLPlatformUtils::Initialize(); if (bRecognizeNEL) XMLPlatformUtils::recognizeNEL(bRecognizeNEL); }

      catch (const XMLException& toCatch){}

      parser = new XercesDOMParser();
      parser->setValidationScheme(valScheme);
      parser->setDoNamespaces(bDoNamespaces);
      parser->setDoSchema(bDoSchema);
      parser->setValidationSchemaFullChecking(bSchemaFullChecking);
      parser->setCreateEntityReferenceNodes(bCreateEntityReferenceNodes);

      try

      { XMLURL url(url_str.c_str()); URLInputSource src(url); // reset document pool parser->resetDocumentPool(); parser->parse(src); m_pDoc = parser->getDocument(); }

      catch(...)

      { rc = -1; }

      if(parser)delete parser;
      // And call the termination method
      XMLPlatformUtils::Terminate();

      return rc;
      }

      int main(){

      while(1)

      { read_url("http://127.0.0.1/abcd/op1.xml"); sleep(2); }

      return 0;

      }

      Attachments

        Activity

          People

            amassari Alberto Massari
            jessezx jesse
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: