Piotr Caban : windowscodecs: Store stream reference in gif decoder.
Module: wine Branch: master Commit: b68112338577ed80424046ce0341ccef249c147c URL: http://source.winehq.org/git/wine.git/?a=commit;h=b68112338577ed80424046ce03... Author: Piotr Caban <piotr(a)codeweavers.com> Date: Thu Mar 12 10:17:12 2015 +0100 windowscodecs: Store stream reference in gif decoder. --- dlls/windowscodecs/gifformat.c | 5 +++++ dlls/windowscodecs/tests/gifformat.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dlls/windowscodecs/gifformat.c b/dlls/windowscodecs/gifformat.c index 7fccb5e..3a82c09 100644 --- a/dlls/windowscodecs/gifformat.c +++ b/dlls/windowscodecs/gifformat.c @@ -578,6 +578,7 @@ static HRESULT create_metadata_reader(const void *data, int data_size, typedef struct { IWICBitmapDecoder IWICBitmapDecoder_iface; IWICMetadataBlockReader IWICMetadataBlockReader_iface; + IStream *stream; BYTE LSD_data[13]; /* Logical Screen Descriptor */ LONG ref; BOOL initialized; @@ -1054,6 +1055,7 @@ static ULONG WINAPI GifDecoder_Release(IWICBitmapDecoder *iface) if (ref == 0) { + IStream_Release(This->stream); This->lock.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->lock); DGifCloseFile(This->gif); @@ -1141,6 +1143,9 @@ static HRESULT WINAPI GifDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL); IStream_Read(pIStream, This->LSD_data, sizeof(This->LSD_data), NULL); + This->stream = pIStream; + IStream_AddRef(This->stream); + This->initialized = TRUE; LeaveCriticalSection(&This->lock); diff --git a/dlls/windowscodecs/tests/gifformat.c b/dlls/windowscodecs/tests/gifformat.c index 2925911..863a91f 100644 --- a/dlls/windowscodecs/tests/gifformat.c +++ b/dlls/windowscodecs/tests/gifformat.c @@ -67,6 +67,7 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size IWICBitmapDecoder *decoder = NULL; IStream *stream; GUID format; + LONG refcount; hmem = GlobalAlloc(0, image_size); data = GlobalLock(hmem); @@ -84,7 +85,8 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), "wrong container format %s\n", wine_dbgstr_guid(&format)); - IStream_Release(stream); + refcount = IStream_Release(stream); + ok(refcount > 0, "expected stream refcount > 0\n"); return decoder; }
participants (1)
-
Alexandre Julliard