1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:47:36 +00:00

LibWeb: Don't get stuck in TreeWalker.nextNode() when current detached

This fixes a hang on https://reddit.com/

Spec bug: https://github.com/whatwg/dom/issues/1102
This commit is contained in:
Andreas Kling 2023-12-03 21:27:51 +01:00
parent f93cab7679
commit dbca63a1db
3 changed files with 21 additions and 0 deletions

View file

@ -221,6 +221,13 @@ JS::ThrowCompletionOr<JS::GCPtr<Node>> TreeWalker::next_node()
// 4. Set temporary to temporarys parent.
temporary = temporary->parent();
// NON-STANDARD: If temporary is null, then return null.
// This prevents us from infinite looping if the current node is not connected.
// Spec bug: https://github.com/whatwg/dom/issues/1102
if (temporary == nullptr) {
return nullptr;
}
}
// 5. Set result to the result of filtering node within this.