From 0462858247c9f43489defeacb102993245970712 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Thu, 18 Jan 2024 17:03:36 -0500 Subject: [PATCH] LibGfx/JPEG: Keep the original CMYK data in memory When decoding a CMYK image and asked for a normal `frame()`, the decoder would convert the CMYK bitmap into an RGB bitmap. Calling `cmyk_frame()` after that point will provoke a null-dereference. --- Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp index cf689edcd1..470f6d4ee8 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp @@ -1709,7 +1709,6 @@ static ErrorOr cmyk_to_rgb(JPEGLoadingContext& context) } } - context.cmyk_bitmap = nullptr; return {}; } @@ -2026,7 +2025,7 @@ ErrorOr JPEGImageDecoderPlugin::frame(size_t index, Option m_context->state = JPEGLoadingContext::State::BitmapDecoded; } - if (m_context->cmyk_bitmap) + if (m_context->cmyk_bitmap && !m_context->bitmap) TRY(cmyk_to_rgb(*m_context)); return ImageFrameDescriptor { m_context->bitmap, 0 };