This will report runtime error if _CRT_INIT(DLL_PROCESS_ATTACH) is called
two or more times.

Without this guard the _CRT_INIT(DLL_PROCESS_ATTACH) may be unexpectely
called multiple times which will break __proc_attached counter and then
also the DLL_PROCESS_DETACH code path.

Startup code from Visual C++ runtime is doing same thing.
---
 mingw-w64-crt/crt/crtdll.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c
index 6829f5a1c136..eefe0e0715bd 100644
--- a/mingw-w64-crt/crt/crtdll.c
+++ b/mingw-w64-crt/crt/crtdll.c
@@ -89,19 +89,16 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD 
dwReason, LPVOID lpreserved)
            }
          Sleep(1000);
        }
-      if (__native_startup_state == __initializing)
+      if (__native_startup_state != __uninitialized)
        {
          _amsg_exit (31);
        }
-      else if (__native_startup_state == __uninitialized)
+      else
        {
          __native_startup_state = __initializing;
          
          if (_initterm_e (__xi_a, __xi_z) != 0)
            return FALSE;
-       }
-      if (__native_startup_state == __initializing)
-       {
          _initterm (__xc_a, __xc_z);
          __native_startup_state = __initialized;
        }
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to