Browse Source

LibWeb: Null check response body in load_fallback_favicon_if_needed()

This fixes a null dereference seen sometimes when fetching a favicon
doesn't work out as expected.
Andreas Kling 1 year ago
parent
commit
f0288e7f94
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp

+ 2 - 1
Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp

@@ -504,7 +504,8 @@ WebIDL::ExceptionOr<void> HTMLLinkElement::load_fallback_favicon_if_needed(JS::N
         };
 
         // 3. Use response's unsafe response as an icon as if it had been declared using the icon keyword.
-        response->unsafe_response()->body()->fully_read(realm, move(process_body), move(process_body_error), global).release_value_but_fixme_should_propagate_errors();
+        if (auto body = response->unsafe_response()->body())
+            body->fully_read(realm, move(process_body), move(process_body_error), global).release_value_but_fixme_should_propagate_errors();
     };
 
     TRY(Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))));