LibGfx/WebPLoader: Survive calling loop_count() before other accessors

Fixes `animation` asserting when reading a webp input.

(The other order of operations is still covered by TestImageWriter.cpp.)
This commit is contained in:
Nico Weber 2024-06-02 20:02:16 -04:00 committed by Andreas Kling
parent de883d6621
commit 857750dfed
Notes: sideshowbarker 2024-07-17 14:33:07 +09:00
2 changed files with 6 additions and 1 deletions

View File

@ -1381,9 +1381,9 @@ TEST_CASE(test_webp_extended_lossless_animated)
EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = TRY_OR_FAIL(Gfx::WebPImageDecoderPlugin::create(file->bytes()));
EXPECT_EQ(plugin_decoder->loop_count(), 42u);
EXPECT_EQ(plugin_decoder->frame_count(), 8u);
EXPECT(plugin_decoder->is_animated());
EXPECT_EQ(plugin_decoder->loop_count(), 42u);
EXPECT_EQ(plugin_decoder->size(), Gfx::IntSize(990, 1050));

View File

@ -639,6 +639,11 @@ size_t WebPImageDecoderPlugin::loop_count()
if (!is_animated())
return 0;
if (m_context->state < WebPLoadingContext::State::ChunksDecoded) {
if (set_error(decode_webp_chunks(*m_context)))
return 0;
}
if (m_context->state < WebPLoadingContext::State::AnimationFrameChunksDecoded) {
if (set_error(decode_webp_animation_frame_chunks(*m_context)))
return 0;