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 {
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);

View File

@ -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;
}