1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 19:55:06 +00:00

LibWeb: Skip decoding favicon.ico if downloaded data is empty

Some sites don't have favicon.ico, so we may get 404 response.
In such cases, ResourceLoader still calls success_callback.
For favicon loading, we are not checking response headers or payload
size.
This will ultimately fail in Gfx::ImageDecoder::try_create().

So avoid unnecessary work by returning early, if data is empty.
This commit is contained in:
Mandar Kulkarni 2021-09-24 20:28:03 +05:30 committed by Andreas Kling
parent 73fe6c541a
commit d787775806

View file

@ -172,6 +172,8 @@ bool FrameLoader::load(LoadRequest& request, Type type)
favicon_url,
[this, favicon_url](auto data, auto&, auto) {
dbgln_if(SPAM_DEBUG, "Favicon downloaded, {} bytes from {}", data.size(), favicon_url);
if (data.is_empty())
return;
RefPtr<Gfx::Bitmap> favicon_bitmap;
auto decoder = Gfx::ImageDecoder::try_create(data);
if (!decoder) {