Nick Reddel created XERCESJ-1661:
------------------------------------

             Summary: NodeIterator issue when current node is detached
                 Key: XERCESJ-1661
                 URL: https://issues.apache.org/jira/browse/XERCESJ-1661
             Project: Xerces2-J
          Issue Type: Bug
            Reporter: Nick Reddel
            Priority: Minor


If a node is removed from the document, and an 'attached' NodeIterator's 
current node has already been removed from the document, 
NodeIteratorImpl.matchNodeOrParent will throw an NPE (since there's no null 
check).

Note, in most uses you'd expect the NodeIterator to have been been detach()-d, 
so this issue should be rare.

Fix:
diff --git a/framework/entity/src/org/apache/xerces/dom/NodeIteratorImpl.java 
b/framework/entity/src/org/apache/xerces/dom/NodeIteratorImpl.java
index cd3b8bb..169825b 100644
--- a/framework/entity/src/org/apache/xerces/dom/NodeIteratorImpl.java
+++ b/framework/entity/src/org/apache/xerces/dom/NodeIteratorImpl.java
@@ -246,7 +246,7 @@
         
         // check if the removed node is an _ancestor_ of the 
         // reference node
-        for (Node n = fCurrentNode; n != fRoot; n = n.getParentNode()) {
+        for (Node n = fCurrentNode; n != fRoot && n != null; n = 
n.getParentNode()) {
             if (node == n) return n;
         }
         return null;



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to