From 071dc6b8a5c3085ba5d3d080eccb7050ece5ec41 Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Fri, 23 Dec 2005 01:26:59 +0000 Subject: [PATCH] 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 --- .../toolkit/profile/src/nsToolkitProfileService.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mozilla/toolkit/profile/src/nsToolkitProfileService.cpp b/mozilla/toolkit/profile/src/nsToolkitProfileService.cpp index fe48a39579c..bca0d49df75 100644 --- a/mozilla/toolkit/profile/src/nsToolkitProfileService.cpp +++ b/mozilla/toolkit/profile/src/nsToolkitProfileService.cpp @@ -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; }