summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-09 22:10:27 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-09 22:10:27 +0000
commit2e64fed81665aa3a1bdfc95143699e03b11b677d (patch)
treebd6af1c54799500578512ce3e5cfc1b817db9b72 /chrome
parentec53718de10ae7669bc5bb1d1115ad5e38037440 (diff)
downloadchromium_src-2e64fed81665aa3a1bdfc95143699e03b11b677d.zip
chromium_src-2e64fed81665aa3a1bdfc95143699e03b11b677d.tar.gz
chromium_src-2e64fed81665aa3a1bdfc95143699e03b11b677d.tar.bz2
Bounds check the tab index before attempting to index into the TabStripModel using it. Under some circumstances, it seems like it's possible for the user to close or otherwise manipulate a Tab whose corresponding entry has already been removed from the model. This might be related to animations and performance constraints.
B=1366019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/tabs/tab_strip.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/chrome/browser/tabs/tab_strip.cc b/chrome/browser/tabs/tab_strip.cc
index 03f6c2e..57a8e32 100644
--- a/chrome/browser/tabs/tab_strip.cc
+++ b/chrome/browser/tabs/tab_strip.cc
@@ -881,13 +881,13 @@ bool TabStrip::IsTabSelected(const Tab* tab) const {
void TabStrip::SelectTab(Tab* tab) {
int index = GetIndexOfTab(tab);
- if (index != -1)
+ if (model_->ContainsIndex(index))
model_->SelectTabContentsAt(index, true);
}
void TabStrip::CloseTab(Tab* tab) {
int tab_index = GetIndexOfTab(tab);
- if (tab_index != -1) {
+ if (model_->ContainsIndex(tab_index)) {
TabContents* contents = model_->GetTabContentsAt(tab_index);
if (contents)
UserMetrics::RecordAction(L"CloseTab_Mouse", contents->profile());
@@ -905,7 +905,7 @@ void TabStrip::CloseTab(Tab* tab) {
bool TabStrip::IsCommandEnabledForTab(
TabStripModel::ContextMenuCommand command_id, const Tab* tab) const {
int index = GetIndexOfTab(tab);
- if (index != -1)
+ if (model_->ContainsIndex(index))
return model_->IsContextMenuCommandEnabled(index, command_id);
return false;
}
@@ -913,7 +913,7 @@ bool TabStrip::IsCommandEnabledForTab(
void TabStrip::ExecuteCommandForTab(
TabStripModel::ContextMenuCommand command_id, Tab* tab) {
int index = GetIndexOfTab(tab);
- if (index != -1)
+ if (model_->ContainsIndex(index))
model_->ExecuteContextMenuCommand(index, command_id);
}
@@ -921,7 +921,7 @@ void TabStrip::StartHighlightTabsForCommand(
TabStripModel::ContextMenuCommand command_id, Tab* tab) {
if (command_id == TabStripModel::CommandCloseTabsOpenedBy) {
int index = GetIndexOfTab(tab);
- if (index != -1) {
+ if (model_->ContainsIndex(index)) {
std::vector<int> indices = model_->GetIndexesOpenedBy(index);
std::vector<int>::const_iterator iter = indices.begin();
for (; iter != indices.end(); ++iter) {
@@ -933,7 +933,7 @@ void TabStrip::StartHighlightTabsForCommand(
}
} else if (command_id == TabStripModel::CommandCloseTabsToRight) {
int index = GetIndexOfTab(tab);
- if (index != -1) {
+ if (model_->ContainsIndex(index)) {
for (int i = index + 1; i < GetTabCount(); ++i) {
Tab* current_tab = GetTabAt(i);
current_tab->StartPulse();