Bug 1354809 - Fix crash in nsMsgGroupView::LoadMessageByViewIndex(). r=jorgk a=jorgk
☠☠ backed out by f39bbe313d6d ☠ ☠
authoralta88 <alta88>
Wed, 20 Sep 2017 10:34:00 +0200
changeset 28611 7159bd45a4f6813f96ad665986bd4e9da2ced430
parent 28610 958254c475a5fbbe93a8ad261d037a21deac9966
child 28612 430b691235dc428f852bbb36eb44fbe519061a93
child 28618 36b8bd635b85a34165e32989796c6e450f64d75b
push id2020
push usermozilla@jorgk.com
push dateThu, 21 Sep 2017 15:25:57 +0000
treeherdercomm-beta@430b691235dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk, jorgk
bugs1354809
Bug 1354809 - Fix crash in nsMsgGroupView::LoadMessageByViewIndex(). r=jorgk a=jorgk
mailnews/base/src/nsMsgGroupView.cpp
--- a/mailnews/base/src/nsMsgGroupView.cpp
+++ b/mailnews/base/src/nsMsgGroupView.cpp
@@ -950,16 +950,19 @@ NS_IMETHODIMP nsMsgGroupView::CellTextFo
     }
     return NS_OK;
   }
   return nsMsgDBView::CellTextForColumn(aRow, aColumnName, aValue);
 }
 
 NS_IMETHODIMP nsMsgGroupView::LoadMessageByViewIndex(nsMsgViewIndex aViewIndex)
 {
+  if (!IsValidIndex(aViewIndex))
+    return NS_MSG_INVALID_DBVIEW_INDEX;
+
   if (m_flags[aViewIndex] & MSG_VIEW_FLAG_DUMMY)
   {
     // if we used to have one item selected, and now we have more than one, we should clear the message pane.
     nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(mMsgWindowWeak));
     nsCOMPtr <nsIMsgWindowCommands> windowCommands;
     if (msgWindow && NS_SUCCEEDED(msgWindow->GetWindowCommands(getter_AddRefs(windowCommands))) && windowCommands)
       windowCommands->ClearMsgPane();
     // since we are selecting a dummy row, we should also clear out m_currentlyDisplayedMsgUri
@@ -996,17 +999,20 @@ int32_t nsMsgGroupView::FindLevelInThrea
 }
 
 
 nsMsgViewIndex nsMsgGroupView::ThreadIndexOfMsg(nsMsgKey msgKey,
                                             nsMsgViewIndex msgIndex /* = nsMsgViewIndex_None */,
                                             int32_t *pThreadCount /* = NULL */,
                                             uint32_t *pFlags /* = NULL */)
 {
-  if (msgIndex != nsMsgViewIndex_None && GroupViewUsesDummyRow())
+  if (!IsValidIndex(msgIndex))
+    return nsMsgViewIndex_None;
+
+  if (GroupViewUsesDummyRow())
   {
     // this case is all we care about at this point.
     if (m_flags[msgIndex] & MSG_VIEW_FLAG_ISTHREAD)
       return msgIndex;
   }
   return nsMsgDBView::ThreadIndexOfMsg(msgKey, msgIndex, pThreadCount, pFlags);
 }