diff options
author | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-06 12:19:34 +0000 |
---|---|---|
committer | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-06 12:19:34 +0000 |
commit | 6d478b1e77dba59521c5eac87bad1e1f6055219d (patch) | |
tree | 23af5ab68284cec4057d5d86703c68dd1d116f67 /chrome/browser/autocomplete/autocomplete_match.cc | |
parent | 379820172ecd66a378c3bf51c58cbb218c8c6844 (diff) | |
download | chromium_src-6d478b1e77dba59521c5eac87bad1e1f6055219d.zip chromium_src-6d478b1e77dba59521c5eac87bad1e1f6055219d.tar.gz chromium_src-6d478b1e77dba59521c5eac87bad1e1f6055219d.tar.bz2 |
Guard Against Bad Classifications
Added safety valve so that there will be no attempt to set an attribute on an string beyond its end.
Also, be consistent in using NSInteger by carrying around |nextOffset| as one.
Enhanced the diagnostic output for the AutocompleteMatch::ValidateClassifications function so that the underlying perpetrator of the problem can more easily be identified.
NOTE: This is a partial fix in that the true underlying cause of the bad classification range has not yet been addressed. So this bug will be left open.
BUG=121703
TEST=Visit http://www.hurriyet.com.tr/. Bring up a new tab. Type 's' into the omnibox. No crash means success.
Review URL: https://chromiumcodereview.appspot.com/10537010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_match.cc')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_match.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_match.cc b/chrome/browser/autocomplete/autocomplete_match.cc index 82d9d2a..13bee33 100644 --- a/chrome/browser/autocomplete/autocomplete_match.cc +++ b/chrome/browser/autocomplete/autocomplete_match.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "base/string_number_conversions.h" #include "base/string_util.h" +#include "chrome/browser/autocomplete/autocomplete.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" @@ -336,9 +337,13 @@ void AutocompleteMatch::ValidateClassifications( for (ACMatchClassifications::const_iterator i(classifications.begin() + 1); i != classifications.end(); ++i) { DCHECK_GT(i->offset, last_offset) - << "Classification unsorted for \"" << text << '"'; + << " Classification for \"" << text << "\" with offset of " << i->offset + << " is unsorted in relation to last offset of " << last_offset + << ". Provider: " << (provider ? provider->name() : "None") << "."; DCHECK_LT(i->offset, text.length()) - << "Classification out of bounds for \"" << text << '"'; + << " Classification of [" << i->offset << "," << text.length() + << "] is out of bounds for \"" << text << "\". Provider: " + << (provider ? provider->name() : "None") << "."; last_offset = i->offset; } } |