Bug 616229 - crash [@ nsMsgXFGroupThread::SetMsgHdrAt(unsigned int, nsIMsgDBHdr*)]. r=irving,a=Standard8
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 04 Mar 2013 21:46:32 +0200
changeset 13671 db4c8f00540ab0ef4b097106717b7061d70fe64c
parent 13670 107bce144716066ecd9a917555a3278b5e306715
child 13672 39d8c27a94da8ebc82fd6069719749876cb15e58
push id56
push userbugzilla@standard8.plus.com
push dateWed, 19 Jun 2013 09:43:24 +0000
reviewersirving, Standard8
bugs616229
Bug 616229 - crash [@ nsMsgXFGroupThread::SetMsgHdrAt(unsigned int, nsIMsgDBHdr*)]. r=irving,a=Standard8
mailnews/base/src/nsMsgGroupThread.cpp
--- a/mailnews/base/src/nsMsgGroupThread.cpp
+++ b/mailnews/base/src/nsMsgGroupThread.cpp
@@ -231,42 +231,42 @@ NS_IMETHODIMP nsMsgGroupThread::RemoveCh
 nsresult nsMsgGroupThread::RemoveChild(nsMsgKey msgKey)
 {
   m_keys.RemoveElement(msgKey);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgGroupThread::RemoveChildHdr(nsIMsgDBHdr *child, nsIDBChangeAnnouncer *announcer)
 {
+  NS_ENSURE_ARG_POINTER(child);
+
   uint32_t flags;
   nsMsgKey key;
-  
-  if (!child)
-    return NS_ERROR_NULL_POINTER;
-  
+
   child->GetFlags(&flags);
   child->GetMessageKey(&key);
-  
+
   // if this was the newest msg, clear the newest msg date so we'll recalc.
   uint32_t date;
   child->GetDateInSeconds(&date);
   if (date == m_newestMsgDate)
     SetNewestMsgDate(0);
 
   if (!(flags & nsMsgMessageFlags::Read))
     ChangeUnreadChildCount(-1);
   nsMsgViewIndex threadIndex = FindMsgHdr(child);
   bool wasFirstChild = threadIndex == 0;
   nsresult rv = RemoveChildAt(threadIndex);
   // if we're deleting the root of a dummy thread, need to update the threadKey
   // and the dummy header at position 0
   if (m_dummy && wasFirstChild && m_keys.Length() > 1)
   {
     nsIMsgDBHdr *newRootChild;
-    GetChildHdrAt(1, &newRootChild);
+    rv = GetChildHdrAt(1, &newRootChild);
+    NS_ENSURE_SUCCESS(rv, rv);
     SetMsgHdrAt(0, newRootChild);
   }
 
   return rv;
 }
 
 nsresult nsMsgGroupThread::ReparentChildrenOf(nsMsgKey oldParent, nsMsgKey newParent, nsIDBChangeAnnouncer *announcer)
 {
@@ -786,18 +786,17 @@ NS_IMETHODIMP nsMsgXFGroupThread::GetNum
   *aNumChildren = m_folders.Count();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgXFGroupThread::GetChildHdrAt(int32_t aIndex, nsIMsgDBHdr **aResult)
 {
   if (aIndex < 0 || aIndex >= m_folders.Count())
     return NS_MSG_MESSAGE_NOT_FOUND;
-  m_folders.ObjectAt(aIndex)->GetMessageHeader(m_keys[aIndex], aResult);
-  return NS_OK;
+  return m_folders.ObjectAt(aIndex)->GetMessageHeader(m_keys[aIndex], aResult);
 }
 
 NS_IMETHODIMP nsMsgXFGroupThread::GetChildKeyAt(int32_t aIndex, nsMsgKey *aResult)
 {
   NS_ASSERTION(false, "shouldn't call this");
   return NS_ERROR_NOT_IMPLEMENTED;
 }