浏览代码

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 年之前
父节点
当前提交
f0288e7f94
共有 1 个文件被更改,包括 2 次插入1 次删除
  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))));