Bug 1776451 - prevent crash during account manager shutdown if folder cache isn't initialized. r=aleca
Differential Revision:
https://phabricator.services.mozilla.com/D150298
--- 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;