You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Nick Reddel (JIRA)" <xe...@xml.apache.org> on 2015/05/15 23:54:00 UTC
[jira] [Created] (XERCESJ-1661) NodeIterator issue when current
node is detached
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: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org