filter: Make sure we don't crash when searching

This only seems to happen when the user searches for something not in
the filter.

Signed-off-by: Anna Schumaker <anna@ocarinaproject.net>
This commit is contained in:
Anna Schumaker 2014-03-26 17:19:40 -04:00 committed by Anna Schumaker
parent cac0aee2e6
commit f207ed94df
2 changed files with 5 additions and 4 deletions

View File

@ -106,17 +106,17 @@ void filter :: search(const std::string &text, std::set<unsigned int> &res)
{
std::list<std::string> parsed;
std::list<std::string>::iterator it;
IndexEntry *found;
parse_text(text, parsed);
if (parsed.size() == 0)
return;
it = parsed.begin();
try {
res = filter_index.find(*it)->values;
} catch (...) {
found = filter_index.find(*it);
if (!found)
return;
}
res = found->values;
for (it++; it != parsed.end(); it++)
find_intersection(*it, res);

View File

@ -69,3 +69,4 @@ test_search "the" "4 5 6 8"
test_search "the ch" "4 6"
test_search "the CH" "4 6"
test_search "the ch y" "4"
test_search "unknown terms" ""