From 243e91f5deade7232612a03b124033c28510cebf Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Thu, 22 Jun 2023 23:54:24 -0400 Subject: [PATCH] LibGfx/JPEG: Don't return an error on empty icc profiles An empty icc profile shouldn't stop our brave decoder. --- Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp index d192955a48..5c4aab8a62 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp @@ -1030,8 +1030,11 @@ static ErrorOr read_huffman_table(JPEGStream& stream, JPEGLoadingContext& static ErrorOr read_icc_profile(JPEGStream& stream, JPEGLoadingContext& context, int bytes_to_read) { // https://www.color.org/technotes/ICC-Technote-ProfileEmbedding.pdf, page 5, "JFIF". - if (bytes_to_read <= 2) - return Error::from_string_literal("icc marker too small"); + if (bytes_to_read <= 2) { + dbgln_if(JPEG_DEBUG, "icc marker too small"); + TRY(stream.discard(bytes_to_read)); + return {}; + } auto chunk_sequence_number = TRY(stream.read_u8()); // 1-based auto number_of_chunks = TRY(stream.read_u8());