Parcourir la source

* protect against empty strings inside the SetThreadDebugNameA and -U functions

git-svn-id: trunk@45237 -
svenbarth il y a 5 ans
Parent
commit
73026618c8
2 fichiers modifiés avec 8 ajouts et 0 suppressions
  1. 2 0
      rtl/unix/cthreads.pp
  2. 6 0
      rtl/win/systhrd.inc

+ 2 - 0
rtl/unix/cthreads.pp

@@ -494,6 +494,8 @@ Type  PINTRTLEvent = ^TINTRTLEvent;
 {$endif}
 {$endif}
     begin
     begin
 {$if defined(Linux) or defined(Android)}
 {$if defined(Linux) or defined(Android)}
+      if ThreadName = '' then
+        Exit;
   {$ifdef dynpthreads}
   {$ifdef dynpthreads}
       if Assigned(pthread_setname_np) then
       if Assigned(pthread_setname_np) then
   {$endif dynpthreads}
   {$endif dynpthreads}

+ 6 - 0
rtl/win/systhrd.inc

@@ -400,6 +400,9 @@ var
     procedure SysSetThreadDebugNameA(threadHandle: TThreadID; const ThreadName: AnsiString);
     procedure SysSetThreadDebugNameA(threadHandle: TThreadID; const ThreadName: AnsiString);
     begin
     begin
 {$ifndef WINCE}
 {$ifndef WINCE}
+      if ThreadName = '' then
+        Exit;
+
       if WinIsDebuggerPresent then
       if WinIsDebuggerPresent then
       begin
       begin
         RaiseMSVCExceptionMethod(threadHandle, ThreadName);
         RaiseMSVCExceptionMethod(threadHandle, ThreadName);
@@ -417,6 +420,9 @@ var
     procedure SysSetThreadDebugNameU(threadHandle: TThreadID; const ThreadName: UnicodeString);
     procedure SysSetThreadDebugNameU(threadHandle: TThreadID; const ThreadName: UnicodeString);
     begin
     begin
 {$ifndef WINCE}
 {$ifndef WINCE}
+      if ThreadName = '' then
+        Exit;
+
       if WinIsDebuggerPresent then
       if WinIsDebuggerPresent then
       begin
       begin
         RaiseMSVCExceptionMethod(threadHandle, AnsiString(ThreadName));
         RaiseMSVCExceptionMethod(threadHandle, AnsiString(ThreadName));