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

r=bsmedberg
This commit is contained in:
timeless%mozdev.org 2005-12-23 01:26:59 +00:00
Родитель de602581d2
Коммит 23ec290fe6
1 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -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;
}