Bug 688135 - crash [@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow*, int*)], r+a=Standard8
authorKent James <kent@caspia.com>
Tue, 26 Mar 2013 10:22:14 -0700
changeset 14978 1e79544624c3dd8832b882a993ff2e15ff0f0a9e
parent 14977 663389de0c654bb33f90e316b4a4e76ee3882689
child 14979 147ec991f2dd4291145cc36d513db0cf36c843a4
push id872
push userbugzilla@standard8.plus.com
push dateTue, 09 Apr 2013 09:16:30 +0000
treeherdercomm-beta@1e79544624c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs688135
Bug 688135 - crash [@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow*, int*)], r+a=Standard8
mailnews/base/util/nsMsgDBFolder.cpp
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -2550,22 +2550,19 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgW
   bool userHasClassified = false;
   // if the user has not classified any messages yet, then we shouldn't bother
   // running the junk mail controls. This creates a better first use experience.
   // See Bug #250084.
   junkMailPlugin->GetUserHasClassified(&userHasClassified);
   if (!userHasClassified)
     filterForJunk = false;
 
-  if (!mDatabase)
-  {
-    rv = GetDatabase();
-    NS_ENSURE_SUCCESS(rv, rv);
-    NS_ENSURE_TRUE(mDatabase, NS_ERROR_NOT_AVAILABLE);
-  }
+  nsCOMPtr<nsIMsgDatabase> database(mDatabase);
+  rv = GetMsgDatabase(getter_AddRefs(database));
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // check if trait processing needed
 
   nsCOMPtr<nsIMsgTraitService> traitService(
       do_GetService("@mozilla.org/msg-trait-service;1", &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t count = 0, *proIndices, *antiIndices;
@@ -2638,17 +2635,17 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgW
     NotifyHdrsNotBeingClassified();
     return NS_OK;
   }
 
   // get the list of new messages
   //
   uint32_t numNewKeys;
   uint32_t *newKeys;
-  rv = mDatabase->GetNewList(&numNewKeys, &newKeys);
+  rv = database->GetNewList(&numNewKeys, &newKeys);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsTArray<nsMsgKey> newMessageKeys;
   // Start from m_saveNewMsgs (and clear its current state).  m_saveNewMsgs is
   // where we stash the list of new messages when we are told to clear the list
   // of new messages by the UI (which purges the list from the nsMsgDatabase).
   newMessageKeys.SwapElements(m_saveNewMsgs);
   if (numNewKeys)
@@ -2660,20 +2657,18 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgW
   nsTArray<nsMsgKey> classifyMsgKeys;
   nsCString uri;
 
   uint32_t numNewMessages = newMessageKeys.Length();
   for (uint32_t i = 0 ; i < numNewMessages ; ++i)
   {
     nsCOMPtr <nsIMsgDBHdr> msgHdr;
     nsMsgKey msgKey = newMessageKeys[i];
-    NS_ASSERTION(mDatabase, "null database");
-    if (mDatabase)
-      rv = mDatabase->GetMsgHdrForKey(msgKey, getter_AddRefs(msgHdr));
-    if (!mDatabase || !NS_SUCCEEDED(rv))
+    rv = database->GetMsgHdrForKey(msgKey, getter_AddRefs(msgHdr));
+    if (!NS_SUCCEEDED(rv))
       continue;
     // per-message junk tests.
     bool filterMessageForJunk = false;
     while (filterForJunk)  // we'll break from this at the end
     {
       nsCString junkScore;
       msgHdr->GetStringProperty("junkscore", getter_Copies(junkScore));
       if (!junkScore.IsEmpty()) // ignore already scored messages.
@@ -2682,18 +2677,18 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgW
       bool whiteListMessage = false;
       spamSettings->CheckWhiteList(msgHdr, &whiteListMessage);
       if (whiteListMessage)
       {
         // mark this msg as non-junk, because we whitelisted it.
 
         nsAutoCString msgJunkScore;
         msgJunkScore.AppendInt(nsIJunkMailPlugin::IS_HAM_SCORE);
-        mDatabase->SetStringProperty(msgKey, "junkscore", msgJunkScore.get());
-        mDatabase->SetStringProperty(msgKey, "junkscoreorigin", "whitelist");
+        database->SetStringProperty(msgKey, "junkscore", msgJunkScore.get());
+        database->SetStringProperty(msgKey, "junkscoreorigin", "whitelist");
         break; // skip this msg since it's in the white list
       }
       filterMessageForJunk = true;
 
       OrProcessingFlags(msgKey, nsMsgProcessingFlags::ClassifyJunk);
       // Since we are junk processing, we want to defer the msgsClassified
       // notification until the junk classification has occurred.  The event
       // is sufficiently reliable that we know this will be handled in