You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem with getTextContent lies in the memory management area. This function goes over child nodes accumulating text in a buffer which it returns to you at the end. Important part to know is that this buffer is allocated on the document heap and will only be freed when you destroy the document. Imagine an application that loads a DOM document at the beginning and then performs multiple queries (which involve calling getTextContent) on this single document.
In our case this is the function BasicContentExecutor::processScript
void BasicContentExecutor::processScript(XERCESC_NS::DOMElement* content) {
// contents were already downloaded in setupDOM, see to SCXML rec 5.8
std::string scriptContent(X(content->getTextContent()));
_callbacks->eval(scriptContent);
}
This simple example will cause huge memory leak. And the leak will be as big as the length of script's text.
So, we should change source code to
void BasicContentExecutor::processScript(XERCESC_NS::DOMElement* content) {
// contents were already downloaded in setupDOM, see to SCXML rec 5.8
std::string scriptContent("");
DOMNode *node = content->getFirstChild();
if (node && node->getNodeType() == DOMNode::TEXT_NODE) {
char *cstr = XMLString::transcode(node->getNodeValue());
scriptContent = cstr;
XMLString::release(&cstr);
}
_callbacks->eval(scriptContent);
}
The text was updated successfully, but these errors were encountered:
The problem with getTextContent lies in the memory management area. This function goes over child nodes accumulating text in a buffer which it returns to you at the end. Important part to know is that this buffer is allocated on the document heap and will only be freed when you destroy the document. Imagine an application that loads a DOM document at the beginning and then performs multiple queries (which involve calling getTextContent) on this single document.
In our case this is the function BasicContentExecutor::processScript
This simple example will cause huge memory leak. And the leak will be as big as the length of script's text.
So, we should change source code to
The text was updated successfully, but these errors were encountered: