summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Faure <[email protected]>2017-07-17 14:13:41 +0200
committerDavid Faure <[email protected]>2017-07-17 14:13:41 +0200
commitf8188f1f86252fe7ccc9fb13fb92ee0de98764b7 (patch)
treee6e8bb44d139fb9ad505607c6a1e839b63257602
parent3ac9292794f851cb6e086ba1b3417c7fced165dd (diff)
Fix crash when deleting multiple emails, due to begin+idx being out of bounds.
Reviewed by Dan Vratil.
-rw-r--r--messagelist/src/core/item.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/messagelist/src/core/item.cpp b/messagelist/src/core/item.cpp
index 9f965b1..3eb0ad7 100644
--- a/messagelist/src/core/item.cpp
+++ b/messagelist/src/core/item.cpp
@@ -348,8 +348,8 @@ int Item::indexOfChildItem(Item *child) const
if (idx > 0) {
const auto begin = d_ptr->mChildItems->cbegin();
const auto end = d_ptr->mChildItems->cend();
- auto fwdIt = begin + idx;
- auto bwdIt = begin + idx;
+ auto fwdIt = begin + qMin(idx, d_ptr->mChildItems->count() - 1);
+ auto bwdIt = fwdIt;
idx = -1; // invalidate idx so it's -1 in case we fail to find the item
while (fwdIt != end || bwdIt != end) {