浏览代码

Bug 1550: Hang when showing overwrite confirmation prompt if GUI font has zero-width tab character

https://winscp.net/tracker/1550

Source commit: 7db97a109717f1c64d343e30faf9dbb96d2a3257
Martin Prikryl 8 年之前
父节点
当前提交
d75ab91dbc
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      source/windows/GUITools.cpp

+ 7 - 0
source/windows/GUITools.cpp

@@ -516,6 +516,7 @@ void __fastcall ApplyTabs(
       if (IsEligibleForApplyingTabs(Line, TabPos, Start, Remaining))
       {
         int Width;
+        int Iterations = 0;
         while ((Width = CalculateWidth(Start, CalculateWidthArg)) < MaxWidth)
         {
           int Wider = CalculateWidth(Start + Padding, CalculateWidthArg);
@@ -526,6 +527,12 @@ void __fastcall ApplyTabs(
             break;
           }
           Start += Padding;
+          Iterations++;
+          // In rare case a tab is zero-width with some strange font (like HYLE)
+          if (Iterations > 100)
+          {
+            break;
+          }
         }
         Lines->Strings[Index] = Start + Remaining;
       }