浏览代码

Bug 1915: Failure when opening some menus while having long text of specific length copied to the Clipboard

https://winscp.net/tracker/1915
(cherry picked from commit 57f5c5b0153bbc196436ed75c92713b4d07f61e2)

Source commit: 0bbfe1deb61035b7bf59b4a302f12a58f891cf49
Martin Prikryl 5 年之前
父节点
当前提交
fe84a255cf
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 5 4
      source/windows/Tools.cpp

+ 5 - 4
source/windows/Tools.cpp

@@ -863,17 +863,18 @@ bool __fastcall TextFromClipboard(UnicodeString & Text, bool Trim)
     {
       // For all current uses (URL pasting, key/fingerprint pasting, known_hosts pasting, "more messages" copying,
       // permissions pasting), 64KB is large enough.
-      const size_t Limit = 64*1024;
+      const int Limit = 64*1024;
       ErrorContext = L"size";
       size_t Size = GlobalSize(Handle);
-      if (Size > Limit)
+      int Len = (Size / sizeof(*AText)) - 1;
+      if (Len > Limit)
       {
-        ErrorContext = FORMAT(L"substring(%d)", (int(Size)));
+        ErrorContext = FORMAT(L"substring(%d,%d)", (int(Size), Len));
         Text = UnicodeString(AText, Limit);
       }
       else
       {
-        ErrorContext = FORMAT(L"string(%d)", (int(Size)));
+        ErrorContext = FORMAT(L"string(%d,%d)", (int(Size), Len));
         Text = AText;
       }
       if (Trim)