mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00:00
LibGfx/PNG: Make invalid sRGB chunk size non-fatal
https://www.haiku-os.org/images/bg-page.png has a size of 0 for example. Just ignoring the chunk instead of assuming that the image is sRGB and has Perceptual rendering intent matches what libpng does (cf `png_handle_sRGB()`), so let's do that too. (All other chunk handlers are still strict about size.)
This commit is contained in:
parent
3b2a7135b2
commit
f7f9f1f47f
1 changed files with 5 additions and 2 deletions
|
@ -1104,8 +1104,11 @@ static ErrorOr<void> process_gAMA(ReadonlyBytes data, PNGLoadingContext& context
|
|||
static ErrorOr<void> process_sRGB(ReadonlyBytes data, PNGLoadingContext& context)
|
||||
{
|
||||
// https://www.w3.org/TR/png/#srgb-standard-colour-space
|
||||
if (data.size() != 1)
|
||||
return Error::from_string_literal("sRGB chunk has an abnormal size");
|
||||
if (data.size() != 1) {
|
||||
// Invalid per spec, but (rarely) happens in the wild. Log and ignore.
|
||||
warnln("warning: PNG sRGB chunk has an abnormal size; ignoring");
|
||||
return {};
|
||||
}
|
||||
|
||||
u8 rendering_intent = data[0];
|
||||
if (rendering_intent > 3)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue