浏览代码

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

git-svn-id: trunk@45237 -
svenbarth 5 年之前
父节点
当前提交
73026618c8
共有 2 个文件被更改,包括 8 次插入0 次删除
  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}
     begin
 {$if defined(Linux) or defined(Android)}
+      if ThreadName = '' then
+        Exit;
   {$ifdef dynpthreads}
       if Assigned(pthread_setname_np) then
   {$endif dynpthreads}

+ 6 - 0
rtl/win/systhrd.inc

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