diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index 7b89b2372e..6cfc5b9c22 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -5064,6 +5064,13 @@ nsresult nsMsgDBView::CollapseByIndex(nsMsgViewIndex index, PRUint32 *pNumCollap NoteChange(index, 1, nsMsgViewNotificationCode::changed); PRInt32 numRemoved = -rowDelta; // don't count first header in thread + if (index + 1 + numRemoved > m_keys.Length()) + { + NS_ERROR("trying to remove too many rows"); + numRemoved -= (index + 1 + numRemoved) - m_keys.Length(); + if (numRemoved <= 0) + return NS_MSG_MESSAGE_NOT_FOUND; + } NoteStartChange(index + 1, rowDelta, nsMsgViewNotificationCode::insertOrDelete); // start at first id after thread. RemoveRows(index + 1, numRemoved);