Commit 807ad357 authored by Connie Wan's avatar Connie Wan Committed by Commit Bot

Check for -1 index in AddTabAt

See the attached bug for the related crash. I wasn't able to repro the crash, but a -1 index seems like a likely candidate. The previous code did catch it: https://chromium-review.googlesource.com/c/chromium/src/+/1999088/10/chrome/browser/ui/views/tabs/tab_strip.cc#b1081
So I added a check in here for a -1 index, to see if that fixes the issue.

Bug: 1049240
Change-Id: I670ae27d0fe3899e2985575eeb395bfbb68f4cef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040060Reviewed-by: default avatarTaylor Bergquist <tbergquist@chromium.org>
Commit-Queue: Connie Wan <connily@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738747}
parent 756acb18
......@@ -2726,6 +2726,11 @@ const Tab* TabStrip::GetLastVisibleTab() const {
int TabStrip::GetViewInsertionIndex(Tab* tab,
base::Optional<int> from_model_index,
int to_model_index) const {
// -1 is treated a sentinel value to indicate a tab is newly added to the
// beginning of the tab strip.
if (to_model_index < 0)
return 0;
// If to_model_index is beyond the end of the tab strip, then the tab is newly
// added to the end of the tab strip. In that case we can just return the last
// TabSlotView view index, which should be at the sum of the number of tabs
......
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