Переглянути джерело

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.
Andreas Kling 1 рік тому
батько
коміт
9c205537e1
1 змінених файлів з 1 додано та 1 видалено
  1. 1 1
      Userland/Libraries/LibWeb/DOM/Document.cpp

+ 1 - 1
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -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,
     // 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
     // because subsequent steps will modify "initial about:blank" to false, which would cause
     // initial navigation to fail in case it was "about:blank".
     // 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()] {
         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();
             return navigable_container->content_navigable_initialized();
         });
         });