Module: wine Branch: master Commit: fc2b2b1bd49a08bfcbd15bda8ab0184a5e0cd285 URL: https://source.winehq.org/git/wine.git/?a=commit;h=fc2b2b1bd49a08bfcbd15bda8...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Nov 14 13:55:48 2018 +0300
wincodecs: Grab TIFF decoder reference when creating frames.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/windowscodecs/tests/tiffformat.c | 13 ++++++++++++- dlls/windowscodecs/tiffformat.c | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/dlls/windowscodecs/tests/tiffformat.c b/dlls/windowscodecs/tests/tiffformat.c index c6ec21a..36de69e 100644 --- a/dlls/windowscodecs/tests/tiffformat.c +++ b/dlls/windowscodecs/tests/tiffformat.c @@ -26,6 +26,15 @@ #include "wincodec.h" #include "wine/test.h"
+#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__) +static void _expect_ref(IUnknown* obj, ULONG ref, int line) +{ + ULONG rc; + IUnknown_AddRef(obj); + rc = IUnknown_Release(obj); + ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc); +} + #define IFD_BYTE 1 #define IFD_ASCII 2 #define IFD_SHORT 3 @@ -407,8 +416,11 @@ static void test_tiff_8bpp_alpha(void) ok(hr == S_OK, "GetFrameCount error %#x\n", hr); ok(frame_count == 1, "expected 1, got %u\n", frame_count);
+ EXPECT_REF(decoder, 1); hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); + EXPECT_REF(decoder, 2); + IWICBitmapDecoder_Release(decoder);
hr = IWICBitmapFrameDecode_GetSize(frame, &width, &height); ok(hr == S_OK, "GetSize error %#x\n", hr); @@ -443,7 +455,6 @@ static void test_tiff_8bpp_alpha(void) ok(data[i] == expected_data[i], "%u: expected %02x, got %02x\n", i, expected_data[i], data[i]);
IWICBitmapFrameDecode_Release(frame); - IWICBitmapDecoder_Release(decoder); }
static void test_tiff_resolution(void) diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c index 5585718..67773fd 100644 --- a/dlls/windowscodecs/tiffformat.c +++ b/dlls/windowscodecs/tiffformat.c @@ -766,6 +766,7 @@ static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface, result->IWICMetadataBlockReader_iface.lpVtbl = &TiffFrameDecode_BlockVtbl; result->ref = 1; result->parent = This; + IWICBitmapDecoder_AddRef(iface); result->index = index; result->decode_info = decode_info; result->cached_tile_x = -1; @@ -776,7 +777,7 @@ static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface, else { hr = E_OUTOFMEMORY; - HeapFree(GetProcessHeap(), 0, result); + IWICBitmapFrameDecode_Release(&result->IWICBitmapFrameDecode_iface); } } else hr = E_OUTOFMEMORY; @@ -851,6 +852,7 @@ static ULONG WINAPI TiffFrameDecode_Release(IWICBitmapFrameDecode *iface)
if (ref == 0) { + IWICBitmapDecoder_Release(&This->parent->IWICBitmapDecoder_iface); HeapFree(GetProcessHeap(), 0, This->cached_tile); HeapFree(GetProcessHeap(), 0, This); }