From 004f9f9a36765fdcb92d6b83d4d69dccba165251 Mon Sep 17 00:00:00 2001 From: Konstantin Isakov Date: Tue, 26 Jul 2011 21:26:59 -0700 Subject: [PATCH] Don't attempt adding very large words into index, they are usually a sign of malformed dictionary and can consume huge amount of resources. --- btreeidx.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/btreeidx.cc b/btreeidx.cc index d9f5d9c8..8daebf1a 100644 --- a/btreeidx.cc +++ b/btreeidx.cc @@ -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 ) ) {