From 7b44b522f359874a3b22ef1cc7d2df2d31dede0f Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Mon, 7 Jan 2002 22:22:12 +0000 Subject: [PATCH] Fix blocker bug 105548 (the mac installer crash). The xpistub code was creating nsLocalFileMac objects, but never refcounting them, so they got deleted before the GetPath() method was called (how did this ever work???). Fixed using COMPtrs. r=ccarlen, a=jj git-svn-id: svn://10.0.0.236/trunk@111505 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpinstall/stub/xpistub.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/mozilla/xpinstall/stub/xpistub.cpp b/mozilla/xpinstall/stub/xpistub.cpp index 3edf06fe2dd..6b97a60f014 100644 --- a/mozilla/xpinstall/stub/xpistub.cpp +++ b/mozilla/xpinstall/stub/xpistub.cpp @@ -103,23 +103,17 @@ PR_PUBLIC_API(nsresult) XPI_Init( // Initialize XPCOM and AutoRegister() its components //-------------------------------------------------------------------- #ifdef XP_MAC - - nsLocalFile *binDir = new nsLocalFile; - if (binDir) - { - binDir->InitWithFSSpec(&aXPIStubDir); - rv = NS_InitXPCOM2(&gServiceMgr, binDir, nsnull); - } - else - return NS_ERROR_FAILURE; - + nsCOMPtr binDir; + rv = NS_NewLocalFileWithFSSpec((FSSpec*)&aXPIStubDir, PR_FALSE, getter_AddRefs(binDir)); + if (NS_FAILED(rv)) return rv; + + rv = NS_InitXPCOM2(&gServiceMgr, binDir, nsnull); + // binDir is contaminated now. Need compDir to pass to AutoRegister. - nsLocalFile *compDir = new nsLocalFile; - if (compDir) - compDir->InitWithFSSpec(&aXPIStubDir); - else - return NS_ERROR_FAILURE; - + nsCOMPtr compDir; + rv = NS_NewLocalFileWithFSSpec((FSSpec*)&aXPIStubDir, PR_FALSE, getter_AddRefs(compDir)); + if (NS_FAILED(rv)) return rv; + #elif defined(XP_PC) char componentPath[MAX_PATH];