From: Kevin Puetz PuetzKevinA@JohnDeere.com
Demonstrate a refcount leak on the class factory when a class with ThreadingModel=Apartment is instantiated in the MTA. CoGetClassObject ends up using apartment_hostobject to launch an STA thread in which to host the object, but the process of marshaling this class factory back into the MTA leaks a reference on it.
This leak is usually minor (class factory implementations are usually singletons, so it's a one-of rather than a cumulative leak), but it will generally lock that COM server and e.g. prevent CoFreeUnusedLibraries from being able to clean up properly.
Signed-off-by: Kevin Puetz PuetzKevinA@JohnDeere.com --- dlls/ole32/tests/compobj.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index 94b83024b91..1ebc92553f7 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -750,6 +750,7 @@ static void test_CoGetClassObject(void) REFCLSID rclsid = &CLSID_InternetZoneManager; HKEY hkey; LONG res; + ULONG refs;
hr = CoGetClassObject(rclsid, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk); ok(hr == CO_E_NOTINITIALIZED, "CoGetClassObject should have returned CO_E_NOTINITIALIZED instead of 0x%08lx\n", hr); @@ -794,7 +795,8 @@ static void test_CoGetClassObject(void)
hr = CoGetClassObject(&CLSID_InProcFreeMarshaler, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk); ok(hr == S_OK, "got 0x%08lx\n", hr); - IUnknown_Release(pUnk); + refs = IUnknown_Release(pUnk); + todo_wine ok(refs == 0, "Expected 0, got %lu\n", refs);
/* context redefines FreeMarshaler CLSID */ if ((handle = activate_context(actctx_manifest, &cookie)))