diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 21:07:50 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 21:07:50 +0000 |
commit | 35e6071b402c63474795843629533a2444f8e8ad (patch) | |
tree | 6d945703a4f986200df0692a77239f37e0558466 /chrome/browser/autocomplete/history_url_provider.cc | |
parent | b238fcb19682be308db4ae4e3b3f322a48d6113b (diff) | |
download | chromium_src-35e6071b402c63474795843629533a2444f8e8ad.zip chromium_src-35e6071b402c63474795843629533a2444f8e8ad.tar.gz chromium_src-35e6071b402c63474795843629533a2444f8e8ad.tar.bz2 |
Fix DCHECK when typing certain kinds of input on certain profiles.
This is actually a very old bug that some of my recent changes exposed more widely. In PromoteOrCreateShorterSuggestion(), we could create a totally bogus search base, which, if added to the history matches, would then break. In the old code, we'd create this match, but usually not add it to the history match set because we'd already have a What You Typed match; in my new code that's frequently no longer the case.
BUG=10926
Review URL: http://codereview.chromium.org/92154
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14470 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/history_url_provider.cc')
-rw-r--r-- | chrome/browser/autocomplete/history_url_provider.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc index 2e91e95..e1b71a9 100644 --- a/chrome/browser/autocomplete/history_url_provider.cc +++ b/chrome/browser/autocomplete/history_url_provider.cc @@ -549,7 +549,8 @@ void HistoryURLProvider::PromoteOrCreateShorterSuggestion( std::string new_match = match.url_info.url().possibly_invalid_spec(). substr(0, match.input_location + params.input.text().length()); search_base = GURL(new_match); - + if (search_base.is_empty()) + return; // Can't construct a valid URL from which to start a search. } else if (!can_add_search_base_to_matches) { can_add_search_base_to_matches = (search_base != what_you_typed_match.destination_url); @@ -828,6 +829,7 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch( CalculateRelevance(params->input.type(), match_type, match_number), !!info.visit_count(), AutocompleteMatch::HISTORY_URL); match.destination_url = info.url(); + DCHECK(match.destination_url.is_valid()); match.fill_into_edit = gfx::GetCleanStringFromUrl(info.url(), match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, NULL, NULL); |