mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
LibGfx: Make PNGLoader not assert on images with missing chunks
Before this, images without IHDR, or palettized images with no or too small PLTE would lead to asserts. Found by running FuzzPNGLoader locally.
This commit is contained in:
parent
7db765bb73
commit
fe999d6281
Notes:
sideshowbarker
2024-07-19 01:10:45 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/fe999d6281b Pull-request: https://github.com/SerenityOS/serenity/pull/4247
1 changed files with 5 additions and 2 deletions
|
@ -747,8 +747,11 @@ static bool decode_png_bitmap(PNGLoadingContext& context)
|
|||
if (context.state >= PNGLoadingContext::State::BitmapDecoded)
|
||||
return true;
|
||||
|
||||
ASSERT(context.width >= 0);
|
||||
ASSERT(context.height >= 0);
|
||||
if (context.width == -1 || context.height == -1)
|
||||
return false; // Didn't see an IHDR chunk.
|
||||
|
||||
if (context.color_type == 3 && context.palette_data.size() < (1u << context.bit_depth))
|
||||
return false; // Didn't see an PLTE chunk for a palettized image, or not enough entries.
|
||||
|
||||
unsigned long srclen = context.compressed_data.size() - 6;
|
||||
unsigned long destlen = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue