Skip to content

Commit

Permalink
remove recursion to make the fuzzer happy
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jan 19, 2023
1 parent 4ee1862 commit 940dc7f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -1453,18 +1453,19 @@ private DomNode getNextElementUpwards(final DomNode startingNode) {
if (startingNode == DomNode.this) {
return null;
}
final DomNode parent = startingNode.getParentNode();
if (parent == null || parent == DomNode.this) {
return null;
}
DomNode next = parent.getNextSibling();
while (next != null && !isAccepted(next)) {
next = next.getNextSibling();
}
if (next == null) {
return getNextElementUpwards(parent);

DomNode parent = startingNode.getParentNode();
while (parent != null && parent != DomNode.this) {
DomNode next = parent.getNextSibling();
while (next != null && !isAccepted(next)) {
next = next.getNextSibling();
}
if (next != null) {
return next;
}
parent = parent.getParentNode();
}
return next;
return null;
}

private DomNode getFirstChildElement(final DomNode parent) {
Expand Down Expand Up @@ -1763,7 +1764,8 @@ public void removeCharacterDataChangeListener(final CharacterDataChangeListener
protected void fireCharacterDataChanged(final CharacterDataChangeEvent event) {
DomNode toInform = this;
while (toInform != null) {
final List<CharacterDataChangeListener> listeners = safeGetCharacterDataListeners();

final List<CharacterDataChangeListener> listeners = toInform.safeGetCharacterDataListeners();
if (listeners != null) {
for (final CharacterDataChangeListener listener : listeners) {
listener.characterDataChanged(event);
Expand Down

0 comments on commit 940dc7f

Please sign in to comment.