From 77cc26878c2c4ca3c801af8a642c123c67514daa Mon Sep 17 00:00:00 2001 From: David Hedberg Date: Tue, 24 May 2011 21:09:47 +0200 Subject: [PATCH] comdlg32: Fix reference counting when querying services. --- dlls/comdlg32/itemdlg.c | 8 +------- dlls/comdlg32/tests/itemdlg.c | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index 8612904d9b6..69d966168f2 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -1915,13 +1915,7 @@ static HRESULT WINAPI IServiceProvider_fnQueryService(IServiceProvider *iface, FIXME("Interface %s requested from unknown service %s\n", debugstr_guid(riid), debugstr_guid(guidService)); - if(SUCCEEDED(hr) && *ppv) - { - IUnknown_AddRef((IUnknown*)*ppv); - return S_OK; - } - - return E_FAIL; + return hr; } static const IServiceProviderVtbl vt_IServiceProvider = { diff --git a/dlls/comdlg32/tests/itemdlg.c b/dlls/comdlg32/tests/itemdlg.c index 36530142d4b..4dafa9b2e6d 100644 --- a/dlls/comdlg32/tests/itemdlg.c +++ b/dlls/comdlg32/tests/itemdlg.c @@ -157,6 +157,7 @@ static BOOL test_instantiation(void) IServiceProvider *psp; IUnknown *punk; HRESULT hr; + LONG ref; /* Instantiate FileOpenDialog */ hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, @@ -223,7 +224,8 @@ static BOOL test_instantiation(void) ok(hr == E_NOINTERFACE, "got 0x%08x.\n", hr); if(SUCCEEDED(hr)) IUnknown_Release(punk); - IFileOpenDialog_Release(pfod); + ref = IFileOpenDialog_Release(pfod); + ok(!ref, "Got refcount %d, should have been released.\n", ref); /* Instantiate FileSaveDialog */ hr = CoCreateInstance(&CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, @@ -267,7 +269,8 @@ static BOOL test_instantiation(void) ok(hr == E_NOINTERFACE, "got 0x%08x.\n", hr); if(SUCCEEDED(hr)) IUnknown_Release(punk); - IFileSaveDialog_Release(pfsd); + ref = IFileSaveDialog_Release(pfsd); + ok(!ref, "Got refcount %d, should have been released.\n", ref); return TRUE; } @@ -284,6 +287,7 @@ static void test_basics(void) LPITEMIDLIST pidl; WCHAR *filename; UINT filetype; + LONG ref; HRESULT hr; const WCHAR txt[] = {'t','x','t', 0}; const WCHAR null[] = {0}; @@ -735,8 +739,10 @@ static void test_basics(void) /* Cleanup */ IShellItem_Release(psidesktop); - IFileOpenDialog_Release(pfod); - IFileSaveDialog_Release(pfsd); + ref = IFileOpenDialog_Release(pfod); + ok(!ref, "Got refcount %d, should have been released.\n", ref); + ref = IFileSaveDialog_Release(pfsd); + ok(!ref, "Got refcount %d, should have been released.\n", ref); } static void test_advise_helper(IFileDialog *pfd) @@ -811,20 +817,23 @@ static void test_advise(void) { IFileDialog *pfd; HRESULT hr; + LONG ref; trace("Testing FileOpenDialog (advise)\n"); hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileDialog, (void**)&pfd); ok(hr == S_OK, "got 0x%08x.\n", hr); test_advise_helper(pfd); - IFileDialog_Release(pfd); + ref = IFileDialog_Release(pfd); + ok(!ref, "Got refcount %d, should have been released.\n", ref); trace("Testing FileSaveDialog (advise)\n"); hr = CoCreateInstance(&CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileDialog, (void**)&pfd); ok(hr == S_OK, "got 0x%08x.\n", hr); test_advise_helper(pfd); - IFileDialog_Release(pfd); + ref = IFileDialog_Release(pfd); + ok(!ref, "Got refcount %d, should have been released.\n", ref); } START_TEST(itemdlg) -- 2.11.4.GIT