diff --git a/search/search_integration_tests/search_query_v2_test.cpp b/search/search_integration_tests/search_query_v2_test.cpp index 01b05d4a27..f010e2135a 100644 --- a/search/search_integration_tests/search_query_v2_test.cpp +++ b/search/search_integration_tests/search_query_v2_test.cpp @@ -506,6 +506,9 @@ UNIT_CLASS_TEST(SearchQueryV2Test, TestCategories) // TEST(my::AlmostEqualAbs(0.0, info.m_nameCoverage, 1e-6), (info.m_nameCoverage)); } } + + // Tests that inexistent hashtagged categories do not crash. + TEST(ResultsMatch("#void-", TRules{}), ()); } } // namespace } // namespace search diff --git a/search/search_query.cpp b/search/search_query.cpp index 4649501c41..7ebce8aee8 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -1264,10 +1264,10 @@ void Query::InitParams(bool localitySearch, SearchQueryParams & params) for (auto & tokens : params.m_tokens) { - if (IsHashtagged(tokens[0])) + if (tokens.size() > 1 && IsHashtagged(tokens[0])) tokens.erase(tokens.begin()); } - if (!params.m_prefixTokens.empty() && IsHashtagged(params.m_prefixTokens[0])) + if (params.m_prefixTokens.size() > 1 && IsHashtagged(params.m_prefixTokens[0])) params.m_prefixTokens.erase(params.m_prefixTokens.begin()); for (int i = 0; i < LANG_COUNT; ++i)