[ https://issues.apache.org/jira/browse/XERCESC-2145?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Blair Fonville updated XERCESC-2145: ------------------------------------ Description: When using Xerces-C++ in a program, which reads (parses) an xml file once into a DOMDocument, and then accesses the DOMDocument's nodes/elements often through getTextContent(), the heap memory builds indefinitely. For example: #include <xercesc/dom/DOM.hpp> XERCES_CPP_NAMESPACE_USE int main(int argc, char **argv) { XMLPlatformUtils::Initialize(); XMLCh tempStr[100]; XMLString::transcode("LS", tempStr, 99); DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr); DOMLSParser *parser = ((DOMImplementationLS*)impl) ->createLSParser( DOMImplementationLS::MODE_SYNCHRONOUS, 0); DOMDocument *doc = impl->createDocument(0, 0, 0); doc = parser->parseURI("config.xml"); DOMElement *el = doc->getDocumentElement(); // Heap blows up here while (1) { char *cstr = XMLString::transcode(el->getTextContent()); XMLString::release(&cstr); } // and/or here while (1) { XMLCh *xstr = XMLString::replicate(el->getTextContent()); char *cstr = XMLString::transcode(xstr); XMLString::release(&cstr); XMLString::release(&xstr); } } was: When using Xerces-C++ in a program, which reads (parses) an xml file once into a DOMDocument, and then accesses the DOMDocument's nodes/elements often through getTextContent(), the heap memory builds indefinitely. For example: #include <xercesc/dom/DOM.hpp> XERCES_CPP_NAMESPACE_USE int main(int argc, char **argv) { XMLPlatformUtils::Initialize(); XMLCh tempStr[100]; XMLString::transcode("LS", tempStr, 99); DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr); DOMLSParser *parser = ((DOMImplementationLS*)impl) ->createLSParser( DOMImplementationLS::MODE_SYNCHRONOUS, 0); DOMDocument *doc = impl->createDocument(0, 0, 0); doc = parser->parseURI("config.xml"); DOMElement *el = doc->getDocumentElement(); // Heap blows up here while (1) {<br> char *cstr = XMLString::transcode(el->getTextContent());<br> XMLString::release(&cstr);<br> }<br> // and/or here while (1) {<br> XMLCh *xstr = XMLString::replicate(el->getTextContent());<br> char *cstr = XMLString::transcode(xstr);<br> XMLString::release(&cstr);<br> XMLString::release(&xstr);<br> } } > indefinite memory allocations using DOMNode::getTextContent() > ------------------------------------------------------------- > > Key: XERCESC-2145 > URL: https://issues.apache.org/jira/browse/XERCESC-2145 > Project: Xerces-C++ > Issue Type: Bug > Components: DOM > Affects Versions: 3.1.2, 3.2.1 > Environment: Windows 10, Visual Studio 2017 > Reporter: Blair Fonville > Priority: Major > Attachments: main.cpp > > > When using Xerces-C++ in a program, which reads (parses) an xml file once > into a DOMDocument, and then accesses the DOMDocument's nodes/elements often > through getTextContent(), the heap memory builds indefinitely. > For example: > #include <xercesc/dom/DOM.hpp> > XERCES_CPP_NAMESPACE_USE > int main(int argc, char **argv) > { > XMLPlatformUtils::Initialize(); > XMLCh tempStr[100]; > XMLString::transcode("LS", tempStr, 99); > DOMImplementation *impl = > DOMImplementationRegistry::getDOMImplementation(tempStr); > DOMLSParser *parser = ((DOMImplementationLS*)impl) > ->createLSParser( DOMImplementationLS::MODE_SYNCHRONOUS, 0); > DOMDocument *doc = impl->createDocument(0, 0, 0); > doc = parser->parseURI("config.xml"); > DOMElement *el = doc->getDocumentElement(); > // Heap blows up here > while (1) { > char *cstr = XMLString::transcode(el->getTextContent()); > XMLString::release(&cstr); > } > // and/or here > while (1) { > XMLCh *xstr = XMLString::replicate(el->getTextContent()); > char *cstr = XMLString::transcode(xstr); > XMLString::release(&cstr); > XMLString::release(&xstr); > } > } > -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org For additional commands, e-mail: c-dev-h...@xerces.apache.org