瀏覽代碼

Fix infinite loop when trimming lines starting with control characters (e.g. \t)

kdmcser 2 周之前
父節點
當前提交
8d82727dd5
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      client/windows/CMessage.cpp

+ 7 - 1
client/windows/CMessage.cpp

@@ -164,7 +164,13 @@ std::vector<std::string> CMessage::breakText(std::string text, size_t maxLineWid
 		{
 		{
 			// trim only if line does not starts with LF
 			// trim only if line does not starts with LF
 			// FIXME: necessary? All lines will be trimmed before returning anyway
 			// FIXME: necessary? All lines will be trimmed before returning anyway
-			boost::algorithm::trim_left_if(text, boost::algorithm::is_any_of(std::string(" ")));
+			boost::algorithm::trim_left_if(
+				text,
+				[](char c)
+				{
+					return static_cast<unsigned char>(c) <= static_cast<unsigned char>(' ');
+				}
+			);
 		}
 		}
 
 
 		if(opened)
 		if(opened)