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.
This commit is contained in:
Lucas CHOLLET 2024-01-18 17:03:36 -05:00 committed by Andrew Kaster
parent 980b61470c
commit 0462858247
Notes: sideshowbarker 2024-07-17 04:34:25 +09:00

View file

@ -1709,7 +1709,6 @@ static ErrorOr<void> cmyk_to_rgb(JPEGLoadingContext& context)
}
}
context.cmyk_bitmap = nullptr;
return {};
}
@ -2026,7 +2025,7 @@ ErrorOr<ImageFrameDescriptor> 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 };