From 4cc2fc4afaedec0d644a6a9e99ba581125c9994a Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sat, 7 Oct 2023 10:08:50 +0100 Subject: [PATCH] LibGfx/PNGLoader: Remove redundant IHDR bit depth validation --- .../LibGfx/ImageFormats/PNGLoader.cpp | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp index 6cbf987481..77f5265570 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp @@ -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 process_IHDR(ReadonlyBytes data, PNGLoadingContext& context) { if (data.size() < (int)sizeof(PNG_IHDR)) @@ -959,11 +943,6 @@ static ErrorOr 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");