diff --git a/Userland/Libraries/LibGfx/ImageFormats/GIFLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/GIFLoader.cpp index f110b1fb57..f72b535788 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/GIFLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/GIFLoader.cpp @@ -417,8 +417,6 @@ static ErrorOr load_header_and_logical_screen(GIFLoadingContext& context) static ErrorOr load_gif_frame_descriptors(GIFLoadingContext& context) { - TRY(load_header_and_logical_screen(context)); - NonnullOwnPtr current_image = make(); for (;;) { u8 sentinel = TRY(context.stream.read_value()); @@ -543,17 +541,6 @@ GIFImageDecoderPlugin::~GIFImageDecoderPlugin() = default; IntSize GIFImageDecoderPlugin::size() { - if (m_context->error_state == GIFLoadingContext::ErrorState::FailedToLoadFrameDescriptors) { - return {}; - } - - if (m_context->state < GIFLoadingContext::State::FrameDescriptorsLoaded) { - if (load_gif_frame_descriptors(*m_context).is_error()) { - m_context->error_state = GIFLoadingContext::ErrorState::FailedToLoadFrameDescriptors; - return {}; - } - } - return { m_context->logical_screen.width, m_context->logical_screen.height }; } @@ -566,7 +553,9 @@ bool GIFImageDecoderPlugin::sniff(ReadonlyBytes data) ErrorOr> GIFImageDecoderPlugin::create(ReadonlyBytes data) { FixedMemoryStream stream { data }; - return adopt_nonnull_own_or_enomem(new (nothrow) GIFImageDecoderPlugin(move(stream))); + auto plugin = TRY(adopt_nonnull_own_or_enomem(new (nothrow) GIFImageDecoderPlugin(move(stream)))); + TRY(load_header_and_logical_screen(*plugin->m_context)); + return plugin; } bool GIFImageDecoderPlugin::is_animated()