windowscodecs: Store stream reference in gif decoder.

This commit is contained in:
Piotr Caban 2015-03-12 10:17:12 +01:00 committed by Alexandre Julliard
parent a181997855
commit b681123385
2 changed files with 8 additions and 1 deletions

View File

@ -578,6 +578,7 @@ static HRESULT create_metadata_reader(const void *data, int data_size,
typedef struct { typedef struct {
IWICBitmapDecoder IWICBitmapDecoder_iface; IWICBitmapDecoder IWICBitmapDecoder_iface;
IWICMetadataBlockReader IWICMetadataBlockReader_iface; IWICMetadataBlockReader IWICMetadataBlockReader_iface;
IStream *stream;
BYTE LSD_data[13]; /* Logical Screen Descriptor */ BYTE LSD_data[13]; /* Logical Screen Descriptor */
LONG ref; LONG ref;
BOOL initialized; BOOL initialized;
@ -1054,6 +1055,7 @@ static ULONG WINAPI GifDecoder_Release(IWICBitmapDecoder *iface)
if (ref == 0) if (ref == 0)
{ {
IStream_Release(This->stream);
This->lock.DebugInfo->Spare[0] = 0; This->lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->lock); DeleteCriticalSection(&This->lock);
DGifCloseFile(This->gif); 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_Seek(pIStream, seek, STREAM_SEEK_SET, NULL);
IStream_Read(pIStream, This->LSD_data, sizeof(This->LSD_data), NULL); IStream_Read(pIStream, This->LSD_data, sizeof(This->LSD_data), NULL);
This->stream = pIStream;
IStream_AddRef(This->stream);
This->initialized = TRUE; This->initialized = TRUE;
LeaveCriticalSection(&This->lock); LeaveCriticalSection(&This->lock);

View File

@ -67,6 +67,7 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size
IWICBitmapDecoder *decoder = NULL; IWICBitmapDecoder *decoder = NULL;
IStream *stream; IStream *stream;
GUID format; GUID format;
LONG refcount;
hmem = GlobalAlloc(0, image_size); hmem = GlobalAlloc(0, image_size);
data = GlobalLock(hmem); data = GlobalLock(hmem);
@ -84,7 +85,8 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size
ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), ok(IsEqualGUID(&format, &GUID_ContainerFormatGif),
"wrong container format %s\n", wine_dbgstr_guid(&format)); "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; return decoder;
} }