From ae6bfa304c421f3a57d70d2ae9074bb7dcf7ddc5 Mon Sep 17 00:00:00 2001 From: R Kent James Date: Wed, 20 Apr 2016 16:22:34 -0700 Subject: [PATCH] Bug 617946 - crash in nsImapMailFolder::GetDatabase() with null database, r=aceman --- mailnews/db/msgdb/src/nsMsgDatabase.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mailnews/db/msgdb/src/nsMsgDatabase.cpp b/mailnews/db/msgdb/src/nsMsgDatabase.cpp index 0b4042b825..97f00cfe7b 100644 --- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp +++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp @@ -390,7 +390,15 @@ NS_IMETHODIMP nsMsgDBService::CreateNewDB(nsIMsgFolder *aFolder, msgDatabase->m_folder = aFolder; rv = msgDatabase->Open(this, summaryFilePath, true, true); - NS_ENSURE_TRUE(rv == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING, rv); + + // We are trying to create a new database, but that implies that it did not + // already exist. Open returns NS_MSG_ERROR_FOLDER_SUMMARY_MISSING for the + // successful creation of a new database. But if it existed for some + // reason, then we would get rv = NS_OK instead. That is a "failure" + // from our perspective, so we want to return a failure since we are not + // returning a valid database object. + NS_ENSURE_TRUE(rv == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING, + NS_SUCCEEDED(rv) ? NS_ERROR_FILE_ALREADY_EXISTS : rv); NS_ADDREF(*_retval = msgDB);