diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-08 12:22:53 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-08 12:22:53 +0000 |
commit | ce21d4a9afd215f8c006b91253cec5ab06b60530 (patch) | |
tree | d1be6b2edb0bffe481a04224c5f4e51a46b84b27 /chrome/browser/importer | |
parent | 981a93c1d8068cd9b1ae13e58f08e12c2bc63b79 (diff) | |
download | chromium_src-ce21d4a9afd215f8c006b91253cec5ab06b60530.zip chromium_src-ce21d4a9afd215f8c006b91253cec5ab06b60530.tar.gz chromium_src-ce21d4a9afd215f8c006b91253cec5ab06b60530.tar.bz2 |
Make sure we don't get an outside array element.
BUG=None
TEST=covered by unit_tests.
Review URL: http://codereview.chromium.org/343076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31401 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer')
-rw-r--r-- | chrome/browser/importer/importer.h | 2 | ||||
-rw-r--r-- | chrome/browser/importer/importer_list.cc | 10 | ||||
-rw-r--r-- | chrome/browser/importer/importer_list.h | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index ee832bd..a8fe226 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -249,7 +249,7 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>, void ImportItemEnded(ImportItem item); void ImportEnded(); - int GetAvailableProfileCount() { + int GetAvailableProfileCount() const { return importer_list_.GetAvailableProfileCount(); } diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc index 4f3c815..c705b51 100644 --- a/chrome/browser/importer/importer_list.cc +++ b/chrome/browser/importer/importer_list.cc @@ -76,24 +76,24 @@ Importer* ImporterList::CreateImporterByType(ProfileType type) { return NULL; } -int ImporterList::GetAvailableProfileCount() { +int ImporterList::GetAvailableProfileCount() const { return static_cast<int>(source_profiles_.size()); } std::wstring ImporterList::GetSourceProfileNameAt(int index) const { - DCHECK(index < static_cast<int>(source_profiles_.size())); + DCHECK(index >=0 && index < GetAvailableProfileCount()); return source_profiles_[index]->description; } const ProfileInfo& ImporterList::GetSourceProfileInfoAt(int index) const { - DCHECK(index < static_cast<int>(source_profiles_.size())); + DCHECK(index >=0 && index < GetAvailableProfileCount()); return *source_profiles_[index]; } const ProfileInfo& ImporterList::GetSourceProfileInfoForBrowserType( int browser_type) const { - int size = source_profiles_.size(); - for (int i = 0; i < size; i++) { + int count = GetAvailableProfileCount(); + for (int i = 0; i < count; ++i) { if (source_profiles_[i]->browser_type == browser_type) return *source_profiles_[i]; } diff --git a/chrome/browser/importer/importer_list.h b/chrome/browser/importer/importer_list.h index 4574a29..9619bb9 100644 --- a/chrome/browser/importer/importer_list.h +++ b/chrome/browser/importer/importer_list.h @@ -44,7 +44,7 @@ class ImporterList { Importer* CreateImporterByType(ProfileType type); // Returns the number of different browser profiles you can import from. - int GetAvailableProfileCount(); + int GetAvailableProfileCount() const; // Returns the name of the profile at the 'index' slot. The profiles are // ordered such that the profile at index 0 is the likely default browser. |