Fix crash in regex search

Avoid unhandled std::range_error exceptions in case of an text input issue by providing an user-supplied byte-error string
see https://en.cppreference.com/w/cpp/locale/wstring_convert/from_bytes and https://en.cppreference.com/w/cpp/locale/wstring_convert/to_bytes

Fix #10773, close #10783
This commit is contained in:
Christian Grasser 2021-11-14 19:55:53 +01:00 committed by Don Ho
parent a22a0bfedf
commit f52c2b022d
1 changed files with 2 additions and 2 deletions

View File

@ -1223,7 +1223,7 @@ bool isAssoCommandExisting(LPCTSTR FullPathName)
std::wstring s2ws(const std::string& str)
{
using convert_typeX = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_typeX, wchar_t> converterX;
std::wstring_convert<convert_typeX, wchar_t> converterX("Error in N++ string conversion s2ws!", L"Error in N++ string conversion s2ws!");
return converterX.from_bytes(str);
}
@ -1231,7 +1231,7 @@ std::wstring s2ws(const std::string& str)
std::string ws2s(const std::wstring& wstr)
{
using convert_typeX = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_typeX, wchar_t> converterX;
std::wstring_convert<convert_typeX, wchar_t> converterX("Error in N++ string conversion ws2s!", L"Error in N++ string conversion ws2s!");
return converterX.to_bytes(wstr);
}