fix crash on startup in nsMsgIdentity::getFolderPref, 480556, r/sr=standard8
authorDavid Bienvenu <bienvenu@nventure.com>
Sat, 28 Feb 2009 14:47:54 -0800
changeset 2101 d3ab31cfee4b9e2672c4aeff0f47561b51fc06ca
parent 2100 c112d8bedf8bc8ee681c00a21ffa8faacc49113d
child 2102 7ce2cdb1e8852785ef2a64c528f34467d9bce29c
push idunknown
push userunknown
push dateunknown
bugs480556
fix crash on startup in nsMsgIdentity::getFolderPref, 480556, r/sr=standard8
mailnews/base/util/nsMsgIdentity.cpp
mailnews/local/src/nsPop3IncomingServer.cpp
--- a/mailnews/base/util/nsMsgIdentity.cpp
+++ b/mailnews/base/util/nsMsgIdentity.cpp
@@ -335,21 +335,24 @@ nsMsgIdentity::getFolderPref(const char 
       rv = accountManager->GetLocalFoldersServer(getter_AddRefs(server));
       NS_ENSURE_SUCCESS(rv, rv);
     }
     nsCOMPtr<nsIMsgFolder> rootFolder;
     // this will get the deferred to server's root folder, if "server"
     // is deferred, e.g., using the pop3 global inbox.
     rv = server->GetRootMsgFolder(getter_AddRefs(rootFolder));
     NS_ENSURE_SUCCESS(rv, rv);
-    rv = rootFolder->GetURI(retval);
-    NS_ENSURE_SUCCESS(rv, rv);
-    retval.Append('/');
-    retval.Append(folderName);
-    return setFolderPref(prefname, retval, folderflag);
+    if (rootFolder)
+    {
+      rv = rootFolder->GetURI(retval);
+      NS_ENSURE_SUCCESS(rv, rv);
+      retval.Append('/');
+      retval.Append(folderName);
+      return setFolderPref(prefname, retval, folderflag);
+    }
   }
   // if there are no servers for this identity, return generic failure.
   return NS_ERROR_FAILURE;
 }
 
 nsresult
 nsMsgIdentity::setFolderPref(const char *prefname, const nsACString& value, PRUint32 folderflag)
 {
--- a/mailnews/local/src/nsPop3IncomingServer.cpp
+++ b/mailnews/local/src/nsPop3IncomingServer.cpp
@@ -265,17 +265,17 @@ nsPop3IncomingServer::GetRootMsgFolder(n
           rv = incomingServer->GetRootMsgFolder(getter_AddRefs(m_rootMsgFolder));
         else
           rv = NS_ERROR_FAILURE;
       }
     }
   }
 
   NS_IF_ADDREF(*aRootMsgFolder = m_rootMsgFolder);
-  return rv;
+  return m_rootMsgFolder ? rv : NS_ERROR_FAILURE;
 }
 
 nsresult nsPop3IncomingServer::GetInbox(nsIMsgWindow *msgWindow, nsIMsgFolder **inbox)
 {
   NS_ENSURE_ARG_POINTER(inbox);
   nsCOMPtr<nsIMsgFolder> rootFolder;
   nsresult rv = GetRootMsgFolder(getter_AddRefs(rootFolder));
   if(NS_SUCCEEDED(rv) && rootFolder)