Bug 1776451 - prevent crash during account manager shutdown if folder cache isn't initialized. r=aleca default tip
authorSean Burke <sean@thunderbird.net>
Fri, 24 Jun 2022 23:22:40 +0000
changeset 36125 4f78bd01de3ed1f77efe6b1509a0c4b4bac4a838
parent 36124 fa52f2ff45286a477b4fc2af0a73fbbfed4bbad9
push id20046
push useralessandro@thunderbird.net
push dateFri, 24 Jun 2022 23:24:48 +0000
treeherdercomm-central@4f78bd01de3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaleca
bugs1776451
Bug 1776451 - prevent crash during account manager shutdown if folder cache isn't initialized. r=aleca Differential Revision: https://phabricator.services.mozilla.com/D150298
mailnews/base/src/nsMsgAccountManager.cpp
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -186,20 +186,23 @@ nsresult nsMsgAccountManager::Shutdown()
   if (NS_SUCCEEDED(rv) && biffService) biffService->Shutdown();
 
   // shutdown removes nsIIncomingServer listener from purge service, so do it
   // after accounts have been unloaded
   nsCOMPtr<nsIMsgPurgeService> purgeService =
       do_GetService(NS_MSGPURGESERVICE_CONTRACTID, &rv);
   if (NS_SUCCEEDED(rv) && purgeService) purgeService->Shutdown();
 
-  // The DTOR is meant to do the flushing, but observed behaviour is
-  // that it doesn't always get called. So flush explicitly.
-  m_msgFolderCache->Flush();
-  m_msgFolderCache = nullptr;
+  if (m_msgFolderCache) {
+    // The DTOR is meant to do the flushing, but observed behaviour is
+    // that it doesn't always get called. So flush explicitly.
+    m_msgFolderCache->Flush();
+    m_msgFolderCache = nullptr;
+  }
+
   m_haveShutdown = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgAccountManager::GetShutdownInProgress(bool* _retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = m_shutdownInProgress;