diff --git a/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp b/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp index befdd0cca13..7715175b6c2 100644 --- a/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp +++ b/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -94,10 +95,13 @@ void SharedImageRequest::fetch_image(JS::Realm& realm, JS::NonnullGCPtrbody()) - response->body()->fully_read(realm, process_body, process_body_error, JS::NonnullGCPtr { realm.global_object() }); - else + // Check for failed fetch response + if (!Fetch::Infrastructure::is_ok_status(response->status()) || !response->body()) { handle_failed_fetch(); + return; + } + + response->body()->fully_read(realm, process_body, process_body_error, JS::NonnullGCPtr { realm.global_object() }); }; m_state = State::Fetching;