DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24693>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24693

DOMNode::getTextContent() corrupts heap

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



------- Additional Comments From [EMAIL PROTECTED]  2003-11-14 00:47 -------
There are a number of problems with this code:

1. There actually is no problem with having Xerces-C objects allocated in the 
same scope as the call to XMLPlatformUtils::Initialize(), but it will become a 
problem if you start calling XMLPlatformUtils::Terminate().  You should scope 
these objects properly:

XMLPlatformUtils::Initialize()

{
   XercesDOMParser  parser;
   ...
}

XMLPlatformUtils::Terminate();

2. There is no problem with calling getNodeName() on any type of node, it's 
just that the name you get back may not be very interesting.  For example, 
you'll get "#text" for text nodes.

3. You are casting using C-style casts, which are an invitation to disaster.

4. You are casting nodes to the wrong types, because you don't understand basic 
concepts of XML.  You are assuming the first child of the 
element "Object1234567890" is an "Obj" element node, but that's not the case.  
The first child is actually a text node that represents the whitespace between 
the two element nodes.  When you cast that DOMText node to a DOMElement node, 
you are casting to the wrong type, so disaster ensues.

Here's a very brief patch the fixes the problem, although I don't recommend it 
for production, because it really relies to0 much on the structure of the input 
document:

if (XMLString::compareIString(name, L"Object1234567890") == 0) 
{
    pChild = pNode->getFirstChild();
    pChild = pChild->getNextSibling();  // Added to fix the bug...

Adding this lines of code fixes the problem and the code runs without problems.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to