Bug 523809 - crash while moving messages [@nsMsgDBView::GetThreadRootIndex(nsIMsgDBHdr*) ] [r/sr=bienvenu, a-tb3=standard8]
authorKent James <kent@caspia.com>
Mon, 26 Oct 2009 08:49:37 -0700
changeset 4245 b3c316ffedb3efe125026c4232c24bc76119d0b8
parent 4244 7b62063ef778898849c9aa47098e7e5cb978d25d
child 4246 ff1147beada3d5a96fe843142061f98628f32cf8
push idunknown
push userunknown
push dateunknown
bugs523809
Bug 523809 - crash while moving messages [@nsMsgDBView::GetThreadRootIndex(nsIMsgDBHdr*) ] [r/sr=bienvenu, a-tb3=standard8]
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgSearchDBView.cpp
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -5307,16 +5307,22 @@ PRInt32 nsMsgDBView::FindLevelInThread(n
   }
   return 1;
 }
 
 // ### Can this be combined with GetIndexForThread??
 nsMsgViewIndex 
 nsMsgDBView::GetThreadRootIndex(nsIMsgDBHdr *msgHdr)
 {
+  if (!msgHdr)
+  {
+    NS_WARNING("null msgHdr parameter");
+    return nsMsgViewIndex_None;
+  }
+
   // Take advantage of the fact that we're already sorted
   // and find the thread root via a binary search.
 
   nsMsgViewIndex highIndex = m_keys.Length();
   nsMsgViewIndex lowIndex = 0;
   IdKeyPtr EntryInfo1, EntryInfo2;
   EntryInfo1.key = nsnull;
   EntryInfo2.key = nsnull;
--- a/mailnews/base/src/nsMsgSearchDBView.cpp
+++ b/mailnews/base/src/nsMsgSearchDBView.cpp
@@ -460,24 +460,24 @@ nsresult nsMsgSearchDBView::AddHdrFromFo
       InsertMsgHdrAt(insertIndex, msgHdr, msgKey, msgFlags, 0);
       NoteChange(insertIndex, 1, nsMsgViewNotificationCode::insertOrDelete);
     }
     else
     {
       // get the thread root index before we add the header, because adding
       // the header can change the sort position.
       nsMsgViewIndex threadIndex = GetThreadRootIndex(threadRoot);
-      NS_ASSERTION(!m_levels[threadIndex], "threadRoot incorrect, or level incorrect");
       viewThread->AddHdr(msgHdr, msgIsReferredTo, posInThread,
                          getter_AddRefs(parent));
       if (threadIndex == nsMsgViewIndex_None)
       {
         NS_ERROR("couldn't find thread index for newly inserted header");
         return NS_OK; // not really OK, but not failure exactly.
       }
+      NS_ASSERTION(!m_levels[threadIndex], "threadRoot incorrect, or level incorrect");
 
       PRBool moveThread = PR_FALSE;
       if (m_sortType == nsMsgViewSortType::byDate)
       {
         PRUint32 newestMsgInThread = 0, msgDate = 0;
         viewThread->GetNewestMsgDate(&newestMsgInThread);
         msgHdr->GetDateInSeconds(&msgDate);
         moveThread = (msgDate == newestMsgInThread);