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:
parent
cac0aee2e6
commit
f207ed94df
|
@ -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);
|
||||
|
|
|
@ -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" ""
|
||||
|
|
Loading…
Reference in New Issue