mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-21 18:15:58 +00:00
LibGfx/PNGLoader: Remove redundant IHDR bit depth validation
This commit is contained in:
parent
bc6ae54b59
commit
4cc2fc4afa
|
@ -926,22 +926,6 @@ static bool is_valid_filter_method(u8 filter_method)
|
|||
return filter_method == 0;
|
||||
}
|
||||
|
||||
static bool is_valid_bit_depth(u8 bit_depth, PNG::ColorType color_type)
|
||||
{
|
||||
switch (bit_depth) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
return color_type == PNG::ColorType::Greyscale || color_type == PNG::ColorType::IndexedColor;
|
||||
case 8:
|
||||
return true;
|
||||
case 16:
|
||||
return color_type != PNG::ColorType::IndexedColor;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static ErrorOr<void> process_IHDR(ReadonlyBytes data, PNGLoadingContext& context)
|
||||
{
|
||||
if (data.size() < (int)sizeof(PNG_IHDR))
|
||||
|
@ -959,11 +943,6 @@ static ErrorOr<void> process_IHDR(ReadonlyBytes data, PNGLoadingContext& context
|
|||
return Error::from_string_literal("Invalid height");
|
||||
}
|
||||
|
||||
if (!is_valid_bit_depth(ihdr.bit_depth, ihdr.color_type)) {
|
||||
dbgln("PNG has invalid bit depth {} for color type {}", ihdr.bit_depth, to_underlying(ihdr.color_type));
|
||||
return Error::from_string_literal("Invalid bit depth");
|
||||
}
|
||||
|
||||
if (!is_valid_compression_method(ihdr.compression_method)) {
|
||||
dbgln("PNG has invalid compression method {}", ihdr.compression_method);
|
||||
return Error::from_string_literal("Unsupported compression method");
|
||||
|
|
Loading…
Reference in a new issue