Bug 1543183 - Add some missing nsresult checks during folder creation. r=mkmelin DONTBUILD
authorBen Campbell <benc@thunderbird.net>
Mon, 27 Jan 2020 12:43:01 +0200
changeset 37138 b35a643cf2dd5630d8876d85b864d27b006516ce
parent 37137 3568d9ea04a66019a373e662ce2a411cb781cfcd
child 37139 64e8cb1308b1d96e071f79c383fcf46264a18467
push id2552
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:24:16 +0000
treeherdercomm-beta@f95a6f4408a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1543183
Bug 1543183 - Add some missing nsresult checks during folder creation. r=mkmelin DONTBUILD
mailnews/local/src/nsLocalMailFolder.cpp
mailnews/local/src/nsMsgBrkMBoxStore.cpp
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -179,16 +179,17 @@ nsMsgLocalMailFolder::GetSubFolders(nsIS
     NS_ENSURE_SUCCESS(rv, NS_MSG_INVALID_OR_MISSING_SERVER);
     nsCOMPtr<nsIMsgPluggableStore> msgStore;
     // need to set this flag here to avoid infinite recursion
     mInitialized = true;
     rv = server->GetMsgStore(getter_AddRefs(msgStore));
     NS_ENSURE_SUCCESS(rv, rv);
     // This should add all existing folders as sub-folders of this folder.
     rv = msgStore->DiscoverSubFolders(this, true);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIFile> path;
     rv = GetFilePath(getter_AddRefs(path));
     if (NS_FAILED(rv)) return rv;
 
     bool directory;
     path->IsDirectory(&directory);
     if (directory) {
--- a/mailnews/local/src/nsMsgBrkMBoxStore.cpp
+++ b/mailnews/local/src/nsMsgBrkMBoxStore.cpp
@@ -962,24 +962,29 @@ nsresult nsMsgBrkMBoxStore::AddSubFolder
     nsAutoString leafName;
     currentFile->GetLeafName(leafName);
     // here we should handle the case where the current file is a .sbd directory
     // w/o a matching folder file, or a directory w/o the name .sbd
     if (nsShouldIgnoreFile(leafName, currentFile)) continue;
 
     nsCOMPtr<nsIMsgFolder> child;
     rv = parent->AddSubfolder(leafName, getter_AddRefs(child));
+    if (NS_FAILED(rv) && rv != NS_MSG_FOLDER_EXISTS) {
+      return rv;
+    }
     if (child) {
       nsString folderName;
       child->GetName(folderName);  // try to get it from cache/db
       if (folderName.IsEmpty()) child->SetPrettyName(leafName);
       if (deep) {
         nsCOMPtr<nsIFile> path;
         rv = child->GetFilePath(getter_AddRefs(path));
-        AddSubFolders(child, path, true);
+        NS_ENSURE_SUCCESS(rv, rv);
+        rv = AddSubFolders(child, path, true);
+        NS_ENSURE_SUCCESS(rv, rv);
       }
     }
   }
   return rv == NS_MSG_FOLDER_EXISTS ? NS_OK : rv;
 }
 
 /* Finds the directory associated with this folder.  That is if the path is
    c:\Inbox, it will return c:\Inbox.sbd if it succeeds.  If that path doesn't