Bug 321057 crash [@ NS_NewToolkitProfileService] because it doesn't handle OOM

r=bsmedberg


git-svn-id: svn://10.0.0.236/trunk@186501 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
timeless%mozdev.org
2005-12-23 01:26:59 +00:00
parent 110904f7e9
commit 071dc6b8a5

View File

@@ -846,15 +846,17 @@ nsToolkitProfileService::LockFactory(PRBool aVal)
nsresult
NS_NewToolkitProfileService(nsIToolkitProfileService* *aResult)
{
nsToolkitProfileService* aThis = new nsToolkitProfileService();
nsresult rv = aThis->Init();
nsToolkitProfileService* profileService = new nsToolkitProfileService();
if (!profileService)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = profileService->Init();
if (NS_FAILED(rv)) {
NS_ERROR("nsToolkitProfileService::Init failed!");
delete aThis;
delete profileService;
return rv;
}
NS_ADDREF(*aResult = aThis);
NS_ADDREF(*aResult = profileService);
return NS_OK;
}