[PATCH] ole32: check ole_inits count in OleUninitialize() ole32/tests: add test for OleInitialize/OleUninitialize own reference counting
Paul Gofman
gofmanp at gmail.com
Tue Jan 12 04:20:14 CST 2016
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
dlls/ole32/ole2.c | 5 +++++
dlls/ole32/tests/compobj.c | 24 ++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c
index 7929d3d..097dbb1 100644
--- a/dlls/ole32/ole2.c
+++ b/dlls/ole32/ole2.c
@@ -229,6 +229,11 @@ void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
{
TRACE("()\n");
+ if (COM_CurrentInfo()->ole_inits == 0)
+ {
+ WARN("ole_inits is already 0\n");
+ return ;
+ }
/*
* If we hit the bottom of the lock stack, free the libraries.
*/
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index 5fe9876..c6ae91e 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -2181,6 +2181,29 @@ static void test_CoInitializeEx(void)
OleUninitialize();
}
+static void test_OleInitialize_InitCounting(void)
+{
+ HRESULT hr;
+ HANDLE thread;
+ IUnknown *pUnk;
+ REFCLSID rclsid = &CLSID_InternetZoneManager;
+
+ hr = pCoInitializeEx(NULL, COINIT_MULTITHREADED);
+ ok(hr == S_OK, "CoInitializeEx(COINIT_MULTITHREADED) failed with error 0x%08x\n", hr);
+
+ hr = OleInitialize(NULL);
+ ok(hr == RPC_E_CHANGED_MODE, "OleInitialize should have returned 0x%08x instead of 0x%08x\n", RPC_E_CHANGED_MODE, hr);
+ OleUninitialize();
+
+ pUnk = (IUnknown *)0xdeadbeef;
+ hr = CoCreateInstance(rclsid, NULL, 0x17, &IID_IUnknown, (void **)&pUnk);
+ ok(hr == S_OK, "CoCreateInstance should have returned 0x%08x instead of 0x%08x\n", S_OK, hr);
+ if (pUnk) IUnknown_Release(pUnk);
+
+ /* Cleanup */
+ CoUninitialize();
+}
+
static void test_OleRegGetMiscStatus(void)
{
ULONG_PTR cookie;
@@ -2871,6 +2894,7 @@ START_TEST(compobj)
test_CoGetContextToken();
test_TreatAsClass();
test_CoInitializeEx();
+ test_OleInitialize_InitCounting();
test_OleRegGetMiscStatus();
test_CoCreateGuid();
test_CoWaitForMultipleHandles();
--
2.5.0
More information about the wine-patches
mailing list