DSL: Fix freezes on some incorrect dictionaries

This commit is contained in:
Abs62 2023-02-04 18:53:35 +03:00
parent 661dd4d140
commit 7e1063f22e

View file

@ -1286,6 +1286,13 @@ void processUnsortedParts( wstring & str, bool strip )
void expandOptionalParts( wstring & str, list< wstring > * result, void expandOptionalParts( wstring & str, list< wstring > * result,
size_t x, bool inside_recurse ) size_t x, bool inside_recurse )
{ {
if( str.size() > 500 )
{
// Don't expand too long headwords - it is highly likely incorrect dictionary
result->push_back( str );
return;
}
list< wstring > expanded; list< wstring > expanded;
list< wstring > * headwords; list< wstring > * headwords;
headwords = inside_recurse ? result : &expanded; headwords = inside_recurse ? result : &expanded;