Prevent error caused by trying to add a posting for an empty term (created by unac on really weird data)

This commit is contained in:
Jean-Francois Dockes 2012-11-16 17:41:14 +01:00
parent 494c57ee9c
commit d68eacc172
2 changed files with 12 additions and 1 deletions

View file

@ -677,6 +677,10 @@ public:
// and remember relative.
m_ts->curpos = pos;
pos += m_ts->basepos;
// Don't try to add empty term Xapian doesnt like it... Safety check
// this should not happen.
if (term.empty())
return true;
string ermsg;
try {
// Index without prefix, using the field-specific weighting

View file

@ -131,6 +131,13 @@ public:
}
return true;
}
// It may happen in some weird cases that the output from unac is
// empty (if the word actually consisted entirely of diacritics ...)
// The consequence is that a phrase search won't work without addional
// slack.
if (otrm.empty())
return true;
else
return TermProc::takeword(otrm, pos, bs, be);
}