diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-28 05:27:09 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-28 05:27:09 +0000 |
commit | 86f30b9ad7616f56c52557b50c5057ed2d1f3273 (patch) | |
tree | 05a7088e45397c6aae201bcd2a6f0f5d52a1e62a /ui/views/view_model.cc | |
parent | 33e2bc2bf3a3429eea5ab366337f4c97ef8f85fb (diff) | |
download | chromium_src-86f30b9ad7616f56c52557b50c5057ed2d1f3273.zip chromium_src-86f30b9ad7616f56c52557b50c5057ed2d1f3273.tar.gz chromium_src-86f30b9ad7616f56c52557b50c5057ed2d1f3273.tar.bz2 |
app_list: Fix possible out of bounds index.
- Fix a problem that could not drop at the last position when dragging
an item out of a folder;
- Fix a case view_model_.Move is called with an out of range target index
when dragging the last item out of folder;
- Add a test for dragging last item and drop it at last slot;
- Speculative fix to protect using an index from data model to modify
view_model_;
- A few more DCHECKs to catch the out-of-bound case;
BUG=370064
TEST=AppListMainViewTest.DragLastItemFromFolderAndDropAtLastSlot
Review URL: https://codereview.chromium.org/298963004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273151 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/view_model.cc')
-rw-r--r-- | ui/views/view_model.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ui/views/view_model.cc b/ui/views/view_model.cc index 5f492f5..a0a7549 100644 --- a/ui/views/view_model.cc +++ b/ui/views/view_model.cc @@ -33,6 +33,11 @@ void ViewModel::Remove(int index) { } void ViewModel::Move(int index, int target_index) { + DCHECK_LT(index, static_cast<int>(entries_.size())); + DCHECK_GE(index, 0); + DCHECK_LT(target_index, static_cast<int>(entries_.size())); + DCHECK_GE(target_index, 0); + if (index == target_index) return; Entry entry(entries_[index]); |