Don't attempt adding very large words into index, they are usually a sign of malformed dictionary and can consume huge amount of resources.

This commit is contained in:
Konstantin Isakov 2011-07-26 21:26:59 -07:00
parent 79dbce2bb3
commit 004f9f9a36

View file

@ -899,6 +899,11 @@ void IndexedWords::addWord( wstring const & word, uint32_t articleOffset )
wchar const * wordBegin = word.c_str();
string::size_type wordSize = word.size();
// Safeguard us against various bugs here. Don't attempt adding words
// which are freakishly huge.
if ( wordSize > 256 )
return;
// Skip any leading whitespace
while( *wordBegin && Folding::isWhitespace( *wordBegin ) )
{