From bed7b33daa71bbf289ec1105953ccb54e3d75050 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Mon, 30 Oct 2023 16:24:55 +0000 Subject: [PATCH] LibGfx/ILBM: Don't attempt to decode a BODY chunk without a color map While this isn't disallowed by the specification, it is not something we currently support. Instead of crashing we now return an error in this case. --- Userland/Libraries/LibGfx/ImageFormats/ILBMLoader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibGfx/ImageFormats/ILBMLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/ILBMLoader.cpp index 9da98c29d2..8ce53f1972 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ILBMLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/ILBMLoader.cpp @@ -298,6 +298,9 @@ static ErrorOr decode_iff_chunks(ILBMLoadingContext& context) if (chunk.type == FourCC("CMAP")) { context.color_table = TRY(decode_cmap_chunk(chunk)); } else if (chunk.type == FourCC("BODY")) { + if (context.color_table.is_empty()) + return Error::from_string_literal("Decoding BODY chunk without a color map is not currently supported"); + TRY(decode_body_chunk(chunk, context)); context.state = ILBMLoadingContext::State::BitmapDecoded; } else if (chunk.type == FourCC("CRNG")) {