fix ref-counting issue with GetAllFolders, fixes shutdown leak, r/sr=standard8, 499446
authorDavid Bienvenu <bienvenu@nventure.com>
Sun, 21 Jun 2009 12:56:38 -0700
changeset 2908 c9cbf5a21a045d8d48ed94604a0b0cf0ae75c56c
parent 2907 304b75390dd0ab6d7a60e29a065b8b6fda982667
child 2909 61c62b2d7ca704f2f51d11f639548c27e7b73a90
push idunknown
push userunknown
push dateunknown
bugs499446
fix ref-counting issue with GetAllFolders, fixes shutdown leak, r/sr=standard8, 499446
mailnews/base/src/nsMsgAccountManager.cpp
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -3091,18 +3091,22 @@ NS_IMETHODIMP nsMsgAccountManager::GetAl
         rootFolder->ListDescendents(allDescendents);
     }
   }
   PRUint32 folderCount;
   rv = allDescendents->Count(&folderCount);
   NS_ENSURE_SUCCESS(rv, rv);
   
   // Create an nsIMutableArray from the nsISupportsArray
+  nsCOMPtr<nsIMsgFolder> folder;
   for (i = 0; i < folderCount; i++)
-    folderArray->AppendElement(allDescendents->ElementAt(i), PR_FALSE);
+  {
+    folder = do_QueryElementAt(allDescendents, i);
+    folderArray->AppendElement(folder, PR_FALSE);
+  }
   NS_ADDREF(*aAllFolders = folderArray);
   return rv;
 }
 
 NS_IMETHODIMP nsMsgAccountManager::OnItemAdded(nsIMsgFolder *parentItem, nsISupports *item)
 {
   nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(item);
   // just kick out with a success code if the item in question is not a folder