[search] Fixed UB in search query cleanup.

This commit is contained in:
Yuri Gorshenin 2016-11-17 13:45:09 +03:00
parent 9cb80242f8
commit 5c37749cb6

View file

@ -382,12 +382,11 @@ void Geocoder::SetParams(Params const & params)
// Filter stop words.
if (m_params.m_tokens.size() > 1)
{
for (auto & v : m_params.m_tokens)
my::EraseIf(v, &IsStopWord);
for (size_t i = 0; i < m_params.GetNumTokens();)
for (size_t i = 0; i < m_params.m_tokens.size();)
{
if (m_params.m_tokens[i].empty())
auto & tokens = m_params.m_tokens[i];
my::EraseIf(tokens, &IsStopWord);
if (tokens.empty())
m_params.RemoveToken(i);
else
++i;