From d1fde625a352b67b06a1ae176bcde3ca62459972 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Mon, 13 Jul 2015 17:09:40 +0800 Subject: [PATCH] windowscodecs: Don't fail to decode GIF if an image has been already loaded. --- dlls/windowscodecs/tests/gifformat.c | 9 --------- dlls/windowscodecs/ungif.c | 9 +++++++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/dlls/windowscodecs/tests/gifformat.c b/dlls/windowscodecs/tests/gifformat.c index 85ffc8f1350..53b4e473bdf 100644 --- a/dlls/windowscodecs/tests/gifformat.c +++ b/dlls/windowscodecs/tests/gifformat.c @@ -459,43 +459,34 @@ static void test_truncated_gif(void) stream = create_stream(gif_with_trailer_2, sizeof(gif_with_trailer_2)); if (!stream) return; hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); -todo_wine ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); -if (hr != S_OK) goto skip_1; hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), "wrong container format %s\n", wine_dbgstr_guid(&format)); IWICBitmapDecoder_Release(decoder); -skip_1: IStream_Release(stream); stream = create_stream(gif_without_trailer_1, sizeof(gif_without_trailer_1)); if (!stream) return; hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); -todo_wine ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); -if (hr != S_OK) goto skip_2; hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), "wrong container format %s\n", wine_dbgstr_guid(&format)); IWICBitmapDecoder_Release(decoder); -skip_2: IStream_Release(stream); stream = create_stream(gif_without_trailer_2, sizeof(gif_without_trailer_2)); if (!stream) return; hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); -todo_wine ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); -if (hr != S_OK) goto skip_3; hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), "wrong container format %s\n", wine_dbgstr_guid(&format)); IWICBitmapDecoder_Release(decoder); -skip_3: IStream_Release(stream); } diff --git a/dlls/windowscodecs/ungif.c b/dlls/windowscodecs/ungif.c index 427b32f6232..b413ff05be2 100644 --- a/dlls/windowscodecs/ungif.c +++ b/dlls/windowscodecs/ungif.c @@ -53,8 +53,10 @@ #include #include "windef.h" #include "winbase.h" - #include "ungif.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wincodecs); static void *ungif_alloc( size_t sz ) { @@ -491,7 +493,10 @@ DGifGetLine(GifFileType * GifFile, * image until empty block (size 0) detected. We use GetCodeNext. */ do if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR) - return GIF_ERROR; + { + WARN("GIF is not properly terminated\n"); + break; + } while (Dummy != NULL) ; } return GIF_OK;