LibWeb: Check for active document in descendant_navigables()

This is not in the spec, but I did see a null pointer dereference here
while browsing the web, and it seems completely harmless for this
function to skip over navigables without an active document.

(cherry picked from commit 56e1c0e7eec813c311c41696063a3a31b4b14f0d)
This commit is contained in:
Andreas Kling authored and Nico Weber committed 2024-11-10 20:06:23 -05:00
1 parent 0897967771
commit c2d89a02c7
1 file changed
+5 -1
+5 -1
View File
@@ -3108,7 +3108,11 @@ Vector<JS::Handle<HTML::Navigable>> Document::descendant_navigables()
return TraversalDecision::Continue;
// 2. Extend navigables with navigableContainer's content navigable's active document's inclusive descendant navigables.
navigables.extend(navigable_container.content_navigable()->active_document()->inclusive_descendant_navigables());
auto document = navigable_container.content_navigable()->active_document();
// AD-HOC: If the descendant navigable doesn't have an active document, just skip over it.
if (!document)
return TraversalDecision::Continue;
navigables.extend(document->inclusive_descendant_navigables());
}
return TraversalDecision::Continue;
});