LibWeb: Add missing navigable null check in Document::open()

I saw a null pointer dereference here on GitHub once, but don't know how
to reproduce, or how we'd get here. Nevertheless, null-checking the
navigable is reasonable so let's do it.
This commit is contained in:
Andreas Kling 2024-05-23 13:57:15 +02:00
parent 63a56a77a2
commit 9c205537e1
Notes: sideshowbarker 2024-07-16 20:12:13 +09:00

View file

@ -556,7 +556,7 @@ WebIDL::ExceptionOr<Document*> Document::open(Optional<String> const&, Optional<
// If document belongs to a child navigable, we need to make sure its initial navigation is done,
// because subsequent steps will modify "initial about:blank" to false, which would cause
// initial navigation to fail in case it was "about:blank".
if (auto navigable = this->navigable(); navigable->container() && !navigable->container()->content_navigable_initialized()) {
if (auto navigable = this->navigable(); navigable && navigable->container() && !navigable->container()->content_navigable_initialized()) {
HTML::main_thread_event_loop().spin_processing_tasks_with_source_until(HTML::Task::Source::NavigationAndTraversal, [navigable_container = navigable->container()] {
return navigable_container->content_navigable_initialized();
});