You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2004/03/02 14:48:16 UTC
cvs commit: xml-xerces/c/src/xercesc/dom/impl DOMParentNode.cpp
amassari 2004/03/02 05:48:16
Modified: c/src/xercesc/dom/impl DOMParentNode.cpp
Log:
If insertBefore(A,A) is invoked, a crash would occur (bug# 26919)
Revision Changes Path
1.15 +6 -2 xml-xerces/c/src/xercesc/dom/impl/DOMParentNode.cpp
Index: DOMParentNode.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMParentNode.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DOMParentNode.cpp 29 Jan 2004 11:44:27 -0000 1.14
+++ DOMParentNode.cpp 2 Mar 2004 13:48:16 -0000 1.15
@@ -187,7 +187,6 @@
if (newChild->getOwnerDocument() != fOwnerDocument)
throw DOMException(DOMException::WRONG_DOCUMENT_ERR, 0);
-
// Prevent cycles in the tree
//only need to do this if the node has children
if(newChild->hasChildNodes()) {
@@ -203,6 +202,11 @@
// refChild must in fact be a child of this node (or 0)
if (refChild!=0 && refChild->getParentNode() != castToNode(this))
throw DOMException(DOMException::NOT_FOUND_ERR,0);
+
+ // if the new node has to be placed before itself, we don't have to do anything
+ // (even worse, we would crash if we continue, as we assume they are two distinct nodes)
+ if (refChild!=0 && newChild->isSameNode(refChild))
+ return newChild;
if (newChild->getNodeType() == DOMNode::DOCUMENT_FRAGMENT_NODE)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org