Commit 9acdcdc0 authored by pkasting@chromium.org's avatar pkasting@chromium.org

Fix possible crash in FinalizeInstantQuery() if AddMatchToMap() fails.

It's not clear to me why this is happening frequently.  This should only fail if there is no default provider, but if that's true how are we doing instant?  ...Whatever.

BUG=128575
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10392184

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138135 0039d316-1c4b-4281-b951-d872f2087c98
parent c9d8f52e
...@@ -136,6 +136,7 @@ void SearchProvider::FinalizeInstantQuery(const string16& input_text, ...@@ -136,6 +136,7 @@ void SearchProvider::FinalizeInstantQuery(const string16& input_text,
&adjusted_input_text); &adjusted_input_text);
const string16 text = adjusted_input_text + suggest_text; const string16 text = adjusted_input_text + suggest_text;
bool results_updated = false;
// Remove any matches that are identical to |text|. We don't use the // Remove any matches that are identical to |text|. We don't use the
// destination_url for comparison as it varies depending upon the index passed // destination_url for comparison as it varies depending upon the index passed
// to TemplateURL::ReplaceSearchTerms. // to TemplateURL::ReplaceSearchTerms.
...@@ -144,6 +145,7 @@ void SearchProvider::FinalizeInstantQuery(const string16& input_text, ...@@ -144,6 +145,7 @@ void SearchProvider::FinalizeInstantQuery(const string16& input_text,
(i->type == AutocompleteMatch::SEARCH_SUGGEST)) && (i->type == AutocompleteMatch::SEARCH_SUGGEST)) &&
(i->fill_into_edit == text)) { (i->fill_into_edit == text)) {
i = matches_.erase(i); i = matches_.erase(i);
results_updated = true;
} else { } else {
++i; ++i;
} }
...@@ -159,10 +161,13 @@ void SearchProvider::FinalizeInstantQuery(const string16& input_text, ...@@ -159,10 +161,13 @@ void SearchProvider::FinalizeInstantQuery(const string16& input_text,
CalculateRelevanceForWhatYouTyped() + 1, CalculateRelevanceForWhatYouTyped() + 1,
AutocompleteMatch::SEARCH_SUGGEST, AutocompleteMatch::SEARCH_SUGGEST,
did_not_accept_default_suggestion, false, &match_map); did_not_accept_default_suggestion, false, &match_map);
DCHECK_EQ(1u, match_map.size()); if (!match_map.empty()) {
matches_.push_back(match_map.begin()->second); matches_.push_back(match_map.begin()->second);
results_updated = true;
}
listener_->OnProviderUpdate(true); if (results_updated || done_)
listener_->OnProviderUpdate(results_updated);
} }
void SearchProvider::Start(const AutocompleteInput& input, void SearchProvider::Start(const AutocompleteInput& input,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment