fix 457751, r=emre, sr=neil, delete imap message, rebuild index, do undo can crash
authorDavid Bienvenu <bienvenu@nventure.com>
Thu, 13 Nov 2008 06:51:53 -0800
changeset 1093 3c4f45a990418f501071e9b73154b2b6ccb435bc
parent 1092 db90feaabfc66942c89ebf49a9e98a4962fde5a4
child 1094 fd72c8c7ad62a3e110e30f9a00ba88751ee61917
push idunknown
push userunknown
push dateunknown
reviewersemre, neil, delete
bugs457751
fix 457751, r=emre, sr=neil, delete imap message, rebuild index, do undo can crash
mailnews/db/msgdb/src/nsMsgDatabase.cpp
--- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp
+++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp
@@ -3015,20 +3015,20 @@ NS_IMETHODIMP nsMsgDatabase::CopyHdrFrom
   if (existingHdr)
   {
     if (key == nsMsgKey_None)
       return NS_MSG_MESSAGE_NOT_FOUND;
 
     nsMsgHdr* sourceMsgHdr = static_cast<nsMsgHdr*>(existingHdr);      // closed system, cast ok
     nsMsgHdr *destMsgHdr = nsnull;
     CreateNewHdr(key, (nsIMsgDBHdr **) &destMsgHdr);
-    if (!destMsgHdr)
+    nsIMdbRow  *sourceRow = sourceMsgHdr->GetMDBRow();
+    if (!destMsgHdr || !sourceRow)
       return NS_MSG_MESSAGE_NOT_FOUND;
 
-    nsIMdbRow  *sourceRow = sourceMsgHdr->GetMDBRow() ;
     nsIMdbRow  *destRow = destMsgHdr->GetMDBRow();
     err = destRow->SetRow(GetEnv(), sourceRow);
     if (NS_SUCCEEDED(err))
     {
       if(addHdrToDB)
         err = AddNewHdrToDB(destMsgHdr, PR_TRUE);
       if (NS_SUCCEEDED(err) && newHdr)
         *newHdr = destMsgHdr;
@@ -3459,16 +3459,17 @@ nsresult nsMsgDatabase::GetUint32Propert
 nsresult nsMsgDatabase::SetUint32Property(nsIMdbRow *row, const char *propertyName, PRUint32 propertyVal)
 {
   struct mdbYarn yarn;
   char  int32StrBuf[20];
   yarn.mYarn_Buf = int32StrBuf;
   yarn.mYarn_Size = sizeof(int32StrBuf);
   yarn.mYarn_Fill = sizeof(int32StrBuf);
 
+  NS_ENSURE_STATE(m_mdbStore); // db might have been closed out from under us.
   if (!row)
     return NS_ERROR_NULL_POINTER;
 
   mdb_token  property_token;
 
   nsresult err = m_mdbStore->StringToToken(GetEnv(),  propertyName, &property_token);
   if (err == NS_OK)
   {