From 8a5f893712f89e1ec9c81b190b9d9d592befc4c2 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 3 Sep 2005 15:04:33 +0000 Subject: [PATCH] Make sure to always call the destructors when the constructors have been called from the dll entry point. --- dlls/winecrt0/dll_entry.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dlls/winecrt0/dll_entry.c b/dlls/winecrt0/dll_entry.c index 2990fb5a037..e2a87c3213f 100644 --- a/dlls/winecrt0/dll_entry.c +++ b/dlls/winecrt0/dll_entry.c @@ -28,13 +28,18 @@ extern BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ); BOOL WINAPI __wine_spec_dll_entry( HINSTANCE inst, DWORD reason, LPVOID reserved ) { - BOOL ret, needs_init = (__wine_spec_init_state != CONSTRUCTORS_DONE); + static BOOL call_fini; + BOOL ret; - if (reason == DLL_PROCESS_ATTACH && needs_init) + if (reason == DLL_PROCESS_ATTACH && __wine_spec_init_state != CONSTRUCTORS_DONE) + { + call_fini = TRUE; _init( __wine_main_argc, __wine_main_argv, __wine_main_environ ); + } ret = DllMain( inst, reason, reserved ); - if (reason == DLL_PROCESS_DETACH && needs_init) _fini(); + if (reason == DLL_PROCESS_DETACH && call_fini) _fini(); + return ret; }