Переглянути джерело

Bug 1620: Hang when opening a menu with any "Paste" command, while clipboard contains large amount of text

https://winscp.net/tracker/1620

Source commit: ecc97f0f240be66623b4424363cd0a02895ee396
Martin Prikryl 7 роки тому
батько
коміт
f477c131d0
1 змінених файлів з 12 додано та 1 видалено
  1. 12 1
      source/windows/Tools.cpp

+ 12 - 1
source/windows/Tools.cpp

@@ -748,7 +748,18 @@ bool __fastcall TextFromClipboard(UnicodeString & Text, bool Trim)
   bool Result = (Handle != NULL);
   if (Result)
   {
-    Text = AText;
+    // 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;
+    size_t Size = GlobalSize(Handle);
+    if (Size > Limit)
+    {
+      Text = UnicodeString(AText, Limit);
+    }
+    else
+    {
+      Text = AText;
+    }
     if (Trim)
     {
       Text = Text.Trim();