Commit f8188f1f authored by David Faure's avatar David Faure

Fix crash when deleting multiple emails, due to begin+idx being out of bounds.

Reviewed by Dan Vratil.
parent 3ac92927
...@@ -348,8 +348,8 @@ int Item::indexOfChildItem(Item *child) const ...@@ -348,8 +348,8 @@ int Item::indexOfChildItem(Item *child) const
if (idx > 0) { if (idx > 0) {
const auto begin = d_ptr->mChildItems->cbegin(); const auto begin = d_ptr->mChildItems->cbegin();
const auto end = d_ptr->mChildItems->cend(); const auto end = d_ptr->mChildItems->cend();
auto fwdIt = begin + idx; auto fwdIt = begin + qMin(idx, d_ptr->mChildItems->count() - 1);
auto bwdIt = begin + idx; auto bwdIt = fwdIt;
idx = -1; // invalidate idx so it's -1 in case we fail to find the item idx = -1; // invalidate idx so it's -1 in case we fail to find the item
while (fwdIt != end || bwdIt != end) { while (fwdIt != end || bwdIt != end) {
......
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