Bug 786683 - check success of GetFilePath() throughout nsMsgBrkMBoxStore.cpp. r=jorgk
authoraceman <acelists@atlas.sk>
Sat, 28 Sep 2019 12:40:00 +0200
changeset 37009 4f8dc02144b194e37b780dbdbb5b54669d11fde9
parent 37008 629098a84b46e290ab42efad51d5204fd5784335
child 37010 3b9226ead3a9f03abeb3d512dce7943b6f886c24
push id395
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:38:57 +0000
reviewersjorgk
bugs786683
Bug 786683 - check success of GetFilePath() throughout nsMsgBrkMBoxStore.cpp. r=jorgk
mailnews/local/src/nsMsgBrkMBoxStore.cpp
--- a/mailnews/local/src/nsMsgBrkMBoxStore.cpp
+++ b/mailnews/local/src/nsMsgBrkMBoxStore.cpp
@@ -566,23 +566,25 @@ nsMsgBrkMBoxStore::GetNewMsgOutputStream
   NS_ENSURE_ARG_POINTER(aReusable);
   NS_ENSURE_ARG_POINTER(aResult);
 
 #ifdef _DEBUG
   NS_ASSERTION(m_streamOutstandingFolder != aFolder, "didn't finish prev msg");
   m_streamOutstandingFolder = aFolder;
 #endif
   *aReusable = true;
+
+  nsresult rv;
   nsCOMPtr<nsIFile> mboxFile;
-  aFolder->GetFilePath(getter_AddRefs(mboxFile));
+  rv = aFolder->GetFilePath(getter_AddRefs(mboxFile));
+  NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIMsgDatabase> db;
   aFolder->GetMsgDatabase(getter_AddRefs(db));
   if (!db && !*aNewMsgHdr) NS_WARNING("no db, and no message header");
-  bool exists;
-  nsresult rv;
+  bool exists = false;
   mboxFile->Exists(&exists);
   if (!exists) {
     rv = mboxFile->Create(nsIFile::NORMAL_FILE_TYPE, 0600);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsCString URI;
   aFolder->GetURI(URI);
@@ -634,17 +636,18 @@ nsMsgBrkMBoxStore::DiscardNewMessage(nsI
 #endif
   uint64_t hdrOffset;
   aNewHdr->GetMessageOffset(&hdrOffset);
   aOutputStream->Close();
   nsCOMPtr<nsIFile> mboxFile;
   nsCOMPtr<nsIMsgFolder> folder;
   nsresult rv = aNewHdr->GetFolder(getter_AddRefs(folder));
   NS_ENSURE_SUCCESS(rv, rv);
-  folder->GetFilePath(getter_AddRefs(mboxFile));
+  rv = folder->GetFilePath(getter_AddRefs(mboxFile));
+  NS_ENSURE_SUCCESS(rv, rv);
   return mboxFile->SetFileSize(hdrOffset);
 }
 
 NS_IMETHODIMP
 nsMsgBrkMBoxStore::FinishNewMessage(nsIOutputStream *aOutputStream,
                                     nsIMsgDBHdr *aNewHdr) {
 #ifdef _DEBUG
   m_streamOutstandingFolder = nullptr;
@@ -683,17 +686,18 @@ nsMsgBrkMBoxStore::GetMsgInputStream(nsI
     *aOffset = int64_t(offset);
     char storeToken[100];
     PR_snprintf(storeToken, sizeof(storeToken), "%lld", *aOffset);
     aMsgHdr->SetStringProperty("storeToken", storeToken);
   } else
     *aOffset = ParseUint64Str(PromiseFlatCString(aMsgToken).get());
   *aReusable = true;
   nsCOMPtr<nsIFile> mboxFile;
-  aMsgFolder->GetFilePath(getter_AddRefs(mboxFile));
+  nsresult rv = aMsgFolder->GetFilePath(getter_AddRefs(mboxFile));
+  NS_ENSURE_SUCCESS(rv, rv);
   return NS_NewLocalFileInputStream(aResult, mboxFile);
 }
 
 NS_IMETHODIMP nsMsgBrkMBoxStore::DeleteMessages(nsIArray *aHdrArray) {
   return ChangeFlags(aHdrArray, nsMsgMessageFlags::Expunged, true);
 }
 
 NS_IMETHODIMP
@@ -782,19 +786,20 @@ nsresult nsMsgBrkMBoxStore::GetOutputStr
   if (m_outputStreams.Get(URI, getter_AddRefs(outputStream))) {
     seekableStream = do_QueryInterface(outputStream);
     rv = seekableStream->Tell(&restorePos);
     if (NS_FAILED(rv)) {
       outputStream = nullptr;
       m_outputStreams.Remove(URI);
     }
   }
-  nsCOMPtr<nsIFile> mboxFile;
-  folder->GetFilePath(getter_AddRefs(mboxFile));
   if (!outputStream) {
+    nsCOMPtr<nsIFile> mboxFile;
+    rv = folder->GetFilePath(getter_AddRefs(mboxFile));
+    NS_ENSURE_SUCCESS(rv, rv);
     rv = MsgGetFileStream(mboxFile, getter_AddRefs(outputStream));
     seekableStream = do_QueryInterface(outputStream);
     if (NS_SUCCEEDED(rv)) m_outputStreams.Put(URI, outputStream);
   }
   return rv;
 }
 
 void nsMsgBrkMBoxStore::SetDBValid(nsIMsgDBHdr *aHdr) {