Browse Source

fixed crashes around bad regular expressions, added try-catch block

ScottBrogden 8 years ago
parent
commit
89fb0a70ca
1 changed files with 11 additions and 3 deletions
  1. 11 3
      RegExFilterHelper.cpp

+ 11 - 3
RegExFilterHelper.cpp

@@ -55,10 +55,18 @@ bool CRegExFilterData::MatchesRegEx(std::wstring &copiedText)
 	//std::wstring input(copiedText);
 	if (m_regEx != _T(""))
 	{
-		std::wregex integer(m_regEx);
-		if (regex_match(copiedText, integer))
+		try 
 		{
-			return true;
+			std::wregex integer(m_regEx);
+			if (regex_match(copiedText, integer))
+			{
+				return true;
+			}
+		}
+		catch (regex_error e) 
+		{
+			CString w(e.what());
+			Log(StrF(_T("MatchesRegEx exception: %s, Code Is: %d"), w, e.code()));
 		}
 	}