Browse Source

* simple fix for 16158, avoid crash on duplicate calling of DLL_PROCESS_DETACH

git-svn-id: trunk@15787 -
marco 15 years ago
parent
commit
df19960f41
1 changed files with 3 additions and 0 deletions
  1. 3 0
      rtl/win/syswin.inc

+ 3 - 0
rtl/win/syswin.inc

@@ -82,6 +82,8 @@ function Dll_entry{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}(const info : TEntry
        DLL_PROCESS_DETACH :
          begin
            Dll_entry:=true; { return value is ignored }
+		   if MainThreadIDWin32=0 then // already been here.
+		     exit;
            If SetJmp(DLLBuf) = 0 then
              FPC_Do_Exit;
            if assigned(Dll_Process_Detach_Hook) then
@@ -91,6 +93,7 @@ function Dll_entry{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}(const info : TEntry
            { Free TLS resources used by ThreadVars }
            SysFiniMultiThreading;
            WinDoneCriticalSection(AttachingThread);
+		   MainThreadIDWin32:=0;
          end;
      end;
   end;