Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/combase/combase.c | 33 +++++++++++++++++++++++++++++++++ dlls/ole32/compobj.c | 29 ----------------------------- 2 files changed, 33 insertions(+), 29 deletions(-)
diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c index da8e97df935..da91d66cc53 100644 --- a/dlls/combase/combase.c +++ b/dlls/combase/combase.c @@ -403,6 +403,36 @@ HRESULT WINAPI InternalTlsAllocData(struct tlsdata **data) return S_OK; }
+static void com_cleanup_tlsdata(void) +{ + struct tlsdata *tlsdata = NtCurrentTeb()->ReservedForOle; + struct init_spy *cursor, *cursor2; + + if (!tlsdata) + return; + + if (tlsdata->apt) + apartment_release(tlsdata->apt); + if (tlsdata->errorinfo) + IErrorInfo_Release(tlsdata->errorinfo); + if (tlsdata->state) + IUnknown_Release(tlsdata->state); + + LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &tlsdata->spies, struct init_spy, entry) + { + list_remove(&cursor->entry); + if (cursor->spy) + IInitializeSpy_Release(cursor->spy); + heap_free(cursor); + } + + if (tlsdata->context_token) + IObjContext_Release(tlsdata->context_token); + + heap_free(tlsdata); + NtCurrentTeb()->ReservedForOle = NULL; +} + /*********************************************************************** * FreePropVariantArray (combase.@) */ @@ -2955,6 +2985,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved) apartment_global_cleanup(); DeleteCriticalSection(®istered_classes_cs); break; + case DLL_THREAD_DETACH: + com_cleanup_tlsdata(); + break; }
return TRUE; diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 748c5c1bdfd..39ccc86b352 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -489,31 +489,6 @@ HRESULT WINAPI ManualResetEvent_CreateInstance(IClassFactory *iface, IUnknown *o return hr; }
-static void COM_TlsDestroy(void) -{ - struct oletls *info = NtCurrentTeb()->ReservedForOle; - if (info) - { - struct init_spy *cursor, *cursor2; - - if (info->apt) apartment_release(info->apt); - if (info->errorinfo) IErrorInfo_Release(info->errorinfo); - if (info->state) IUnknown_Release(info->state); - - LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &info->spies, struct init_spy, entry) - { - list_remove(&cursor->entry); - if (cursor->spy) IInitializeSpy_Release(cursor->spy); - heap_free(cursor); - } - - if (info->context_token) IObjContext_Release(info->context_token); - - HeapFree(GetProcessHeap(), 0, info); - NtCurrentTeb()->ReservedForOle = NULL; - } -} - /****************************************************************************** * CoBuildVersion [OLE32.@] * @@ -1324,10 +1299,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID reserved) release_std_git(); RPC_UnregisterAllChannelHooks(); break; - - case DLL_THREAD_DETACH: - COM_TlsDestroy(); - break; } return TRUE; }