protect against obj-c exceptions in uriloader. b=419390 r/sr=roc
authorjoshmoz@gmail.com
Tue, 04 Mar 2008 00:14:47 -0800
changeset 12538 ca9734086a62ccf9b9da3489175a026c35f9996d
parent 12537 164c5b3f4bfe6dcf1cc2c24b40fce3482438cf03
child 12539 480f9fda06b6979b31f8fe65691a2a14b9d4d494
push idunknown
push userunknown
push dateunknown
bugs419390
milestone1.9b5pre
protect against obj-c exceptions in uriloader. b=419390 r/sr=roc
uriloader/exthandler/mac/nsInternetConfig.mm
uriloader/exthandler/mac/nsInternetConfigService.mm
uriloader/exthandler/mac/nsLocalHandlerAppMac.mm
uriloader/exthandler/mac/nsMIMEInfoMac.mm
uriloader/exthandler/mac/nsOSHelperAppService.mm
--- a/uriloader/exthandler/mac/nsInternetConfig.mm
+++ b/uriloader/exthandler/mac/nsInternetConfig.mm
@@ -29,46 +29,53 @@
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
- 
+
 #include "nsInternetConfig.h"
+#include "nsObjCExceptions.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsDebug.h"
 
 #include <Processes.h>
 ICInstance nsInternetConfig::sInstance = NULL;
 long nsInternetConfig::sSeed = 0;
 PRInt32  nsInternetConfig::sRefCount = 0;
 
 
 
 static OSType GetAppCreatorCode()
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
+
   ProcessSerialNumber psn = { 0, kCurrentProcess } ;
   ProcessInfoRec      procInfo;
   
   procInfo.processInfoLength = sizeof(ProcessInfoRec);
   procInfo.processName = nsnull;
   procInfo.processAppSpec = nsnull;
   
   GetProcessInformation(&psn, &procInfo);
-  return procInfo.processSignature;  
+  return procInfo.processSignature;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0x0);
 }
 
 
 
 ICInstance nsInternetConfig::GetInstance()
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
+
 	if ( !sInstance )
 	{
 		OSStatus err;
 		if ((long)ICStart == kUnresolvedCFragSymbolAddress )
 			return sInstance;                          
                                                                                  
                                                                                   
 		OSType creator = GetAppCreatorCode();
@@ -78,41 +85,51 @@ ICInstance nsInternetConfig::GetInstance
 			::ICStop( sInstance );
 		}
 		else
 		{
 			::ICGetSeed( sInstance, &sSeed );
 		}
 	}
 	return sInstance;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NULL);
 }
 
 PRBool nsInternetConfig::HasSeedChanged()
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
+
 	ICInstance instance = nsInternetConfig::GetInstance();
 	if ( instance )
 	{
 		long newSeed = 0;
 		::ICGetSeed( sInstance, &newSeed );
 		if ( newSeed != sSeed )
 		{
 			sSeed = newSeed;
 			return PR_TRUE;
 		}
 	}
 	return PR_FALSE;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(PR_FALSE);
 }
 
 nsInternetConfig::nsInternetConfig()
 {
 	sRefCount++;
 }
 
 nsInternetConfig::~nsInternetConfig()
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
 	sRefCount--;
 	if ( sRefCount == 0 && sInstance)
 	{
 		::ICStop( sInstance );
 		sInstance = NULL;
 	}
+
+  NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
--- a/uriloader/exthandler/mac/nsInternetConfigService.mm
+++ b/uriloader/exthandler/mac/nsInternetConfigService.mm
@@ -32,36 +32,32 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsInternetConfigService.h"
+#include "nsObjCExceptions.h"
 #include "nsCOMPtr.h"
 #include "nsIMIMEInfo.h"
 #include "nsMIMEInfoMac.h"
 #include "nsAutoPtr.h"
 #include "nsIFactory.h"
 #include "nsIComponentManager.h"
 #include "nsIURL.h"
 #include "nsXPIDLString.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 #include "nsCRT.h"
 #include "nsILocalFileMac.h"
 #include "nsMimeTypes.h"
-#include <TextUtils.h>
-#include <CodeFragments.h>
-#include <Processes.h>
-#include <Gestalt.h>
-#include <CFURL.h>
-#include <Finder.h>
-#include <LaunchServices.h>
+
+#import <Carbon/Carbon.h>
 
 
 // helper converter function.....
 static void ConvertCharStringToStr255(const char* inString, Str255& outString)
 {
   if (inString == NULL)
     return;
   
@@ -91,50 +87,60 @@ nsInternetConfigService::~nsInternetConf
  */
 NS_IMPL_ISUPPORTS1(nsInternetConfigService, nsIInternetConfigService)
 
 // void LaunchURL (in string url);
 // Given a url string, call ICLaunchURL using url
 // Under OS X use LaunchServices instead of IC
 NS_IMETHODIMP nsInternetConfigService::LaunchURL(const char *url)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult rv = NS_ERROR_FAILURE; 
 
   CFURLRef myURLRef = ::CFURLCreateWithBytes(
                                              kCFAllocatorDefault,
                                              (const UInt8*)url,
                                              strlen(url),
                                              kCFStringEncodingUTF8, NULL);
   if (myURLRef)
   {
     rv = ::LSOpenCFURLRef(myURLRef, NULL);
     ::CFRelease(myURLRef);
   }
 
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 // boolean HasMappingForMIMEType (in string mimetype);
 // given a mime type, search Internet Config database for a mapping for that mime type
 NS_IMETHODIMP nsInternetConfigService::HasMappingForMIMEType(const char *mimetype, PRBool *_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   ICMapEntry entry;
   nsresult rv = GetMappingForMIMEType(mimetype, nsnull, &entry);
   if (rv == noErr)
     *_retval = PR_TRUE;
   else
     *_retval = PR_FALSE;
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 /* boolean hasProtocolHandler (in string protocol); */
 // returns NS_ERROR_NOT_AVAILABLE if the current application is registered
 // as the protocol handler for the given protocol
 NS_IMETHODIMP nsInternetConfigService::HasProtocolHandler(const char *protocol, PRBool *_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   *_retval = PR_FALSE;            // presume the OS doesn't have a handler
   nsresult rv = NS_OK;
 
   // Since protocol comes in with _just_ the protocol we have to add a ':' to
   // the end of it or LaunchServices will be very unhappy with the CFURLRef
   // created from it (crashes trying to look up a handler for it with
   // LSGetApplicationForURL, at least under 10.2.1)
   nsCAutoString scheme(protocol);
@@ -166,22 +172,26 @@ NS_IMETHODIMP nsInternetConfigService::H
           }
         }
       }
     }
     ::CFRelease(myURLRef);
   }
 
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 // This method does the dirty work of traipsing through IC mappings database
 // looking for a mapping for mimetype
 nsresult nsInternetConfigService::GetMappingForMIMEType(const char *mimetype, const char *fileextension, ICMapEntry *entry)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   ICInstance  inst = nsInternetConfig::GetInstance();
   OSStatus    err = noErr;
   ICAttr      attr;
   Handle      prefH;
   PRBool      domimecheck = PR_TRUE;
   PRBool      gotmatch = PR_FALSE;
   ICMapEntry  ent;
   
@@ -268,16 +278,18 @@ nsresult nsInternetConfigService::GetMap
       }
     }
   }
   
   if (err != noErr)
     return NS_ERROR_FAILURE;
   else
     return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 nsresult nsInternetConfigService::FillMIMEInfoForICEntry(ICMapEntry& entry, nsIMIMEInfo ** mimeinfo)
 {
   // create a mime info object and we'll fill it in based on the values from IC mapping entry
   nsresult  rv = NS_OK;
   nsRefPtr<nsMIMEInfoMac> info (new nsMIMEInfoMac());
   if (info)
@@ -366,56 +378,66 @@ NS_IMETHODIMP nsInternetConfigService::F
   else
     rv = NS_ERROR_FAILURE;
 
   return rv;
 }
 
 NS_IMETHODIMP nsInternetConfigService::GetMIMEInfoFromExtension(const char *aFileExt, nsIMIMEInfo **_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult    rv = NS_ERROR_FAILURE;
   ICInstance  instance = nsInternetConfig::GetInstance();
   if (instance)
   {
     nsCAutoString filename("foobar.");
     filename += aFileExt;
     Str255  pFileName;
     ConvertCharStringToStr255(filename.get(), pFileName);
     ICMapEntry  entry;
     OSStatus  err = ::ICMapFilename(instance, pFileName, &entry);
     if (err == noErr)
     {
       rv = FillMIMEInfoForICEntry(entry, _retval);
     }
   }   
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 NS_IMETHODIMP nsInternetConfigService::GetMIMEInfoFromTypeCreator(PRUint32 aType, PRUint32 aCreator, const char *aFileExt, nsIMIMEInfo **_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult    rv = NS_ERROR_FAILURE;
   ICInstance  instance = nsInternetConfig::GetInstance();
   if (instance)
   {
     nsCAutoString filename("foobar.");
     filename += aFileExt;
     Str255  pFileName;
     ConvertCharStringToStr255(filename.get(), pFileName);
     ICMapEntry  entry;
     OSStatus  err = ::ICMapTypeCreator(instance, aType, aCreator, pFileName, &entry);
     if (err == noErr)
       rv = FillMIMEInfoForICEntry(entry,_retval);
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 NS_IMETHODIMP nsInternetConfigService::GetFileMappingFlags(FSSpec* fsspec, PRBool lookupByExtensionFirst, PRInt32 *_retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult  rv = NS_ERROR_FAILURE;
   OSStatus  err = noErr;
 
   NS_ENSURE_ARG(_retval);
   *_retval = -1;
   
   ICInstance instance = nsInternetConfig::GetInstance();
   if (instance)
@@ -434,22 +456,26 @@ NS_IMETHODIMP nsInternetConfigService::G
     }
 
     if (err == noErr)
       *_retval = entry.flags;
      
      rv = NS_OK;
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 /* void GetDownloadFolder (out FSSpec fsspec); */
 NS_IMETHODIMP nsInternetConfigService::GetDownloadFolder(FSSpec *fsspec)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   ICInstance  inst = nsInternetConfig::GetInstance();
   OSStatus    err;
   Handle      prefH;
   nsresult    rv = NS_ERROR_FAILURE;
   
   NS_ENSURE_ARG_POINTER(fsspec);
   
   if (inst)
@@ -488,16 +514,18 @@ NS_IMETHODIMP nsInternetConfigService::G
         }
         // Best not to leave that handle laying around
         DisposeHandle(prefH);
       }
       err = ::ICEnd(inst);
     }
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 nsresult nsInternetConfigService::GetICKeyPascalString(PRUint32 inIndex, const unsigned char*& outICKey)
 {
   nsresult  rv = NS_OK;
 
   switch (inIndex)
   {
@@ -563,16 +591,18 @@ nsresult nsInternetConfigService::GetICK
   }
   return rv;
 }
 
 
 nsresult nsInternetConfigService::GetICPreference(PRUint32 inKey, 
                                                   void *outData, long *ioSize)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   const unsigned char *icKey;
   nsresult  rv = GetICKeyPascalString(inKey, icKey);
   if (rv == NS_OK)
   {
     ICInstance  instance = nsInternetConfig::GetInstance();
     if (instance)
     {
       OSStatus  err;
@@ -580,16 +610,18 @@ nsresult nsInternetConfigService::GetICP
       err = ::ICGetPref(instance, icKey, &junk, outData, ioSize);
       if (err != noErr)
         rv = NS_ERROR_UNEXPECTED;
     }
     else
       rv = NS_ERROR_FAILURE;
   }
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 NS_IMETHODIMP nsInternetConfigService::GetString(PRUint32 inKey, nsACString& value)
 {
   long      size = 256;
   char      buffer[256];
   nsresult  rv = GetICPreference(inKey, (void *)&buffer, &size);
--- a/uriloader/exthandler/mac/nsLocalHandlerAppMac.mm
+++ b/uriloader/exthandler/mac/nsLocalHandlerAppMac.mm
@@ -30,31 +30,34 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include <LaunchServices.h>
+#import <Carbon/Carbon.h>
 
+#include "nsObjCExceptions.h"
 #include "nsLocalHandlerAppMac.h"
 #include "nsILocalFileMac.h"
 #include "nsIURI.h"
 
 /** 
  * mostly copy/pasted from nsMacShellService.cpp (which is in browser/,
  * so we can't depend on it here).  This code probably really wants to live
  * somewhere more central (see bug 389922).
  */
 NS_IMETHODIMP
 nsLocalHandlerAppMac::LaunchWithURI(nsIURI *aURI,
                                     nsIInterfaceRequestor *aWindowContext)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult rv;
   nsCOMPtr<nsILocalFileMac> lfm(do_QueryInterface(mExecutable, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   
   CFURLRef appURL;
   rv = lfm->GetCFURL(&appURL);
   if (NS_FAILED(rv))
     return rv;
@@ -87,9 +90,11 @@ nsLocalHandlerAppMac::LaunchWithURI(nsIU
   
   OSErr err = ::LSOpenFromURLSpec(&launchSpec, NULL);
   
   ::CFRelease(uris);
   ::CFRelease(uri);
   ::CFRelease(appURL);
   
   return err != noErr ? NS_ERROR_FAILURE : NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
--- a/uriloader/exthandler/mac/nsMIMEInfoMac.mm
+++ b/uriloader/exthandler/mac/nsMIMEInfoMac.mm
@@ -35,26 +35,29 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include <LaunchServices.h>
+#import <Carbon/Carbon.h>
 
+#include "nsObjCExceptions.h"
 #include "nsMIMEInfoMac.h"
 #include "nsILocalFileMac.h"
 #include "nsIFileURL.h"
 #include "nsIInternetConfigService.h"
 
 NS_IMETHODIMP
 nsMIMEInfoMac::LaunchWithFile(nsIFile *aFile)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsCOMPtr<nsIFile> application;
   nsresult rv;
 
   NS_ASSERTION(mClass == eMIMEInfo, "only MIME infos are currently allowed"
                "to pass content by value");
   
   if (mPreferredAction == useHelperApp) {
 
@@ -92,17 +95,19 @@ nsMIMEInfoMac::LaunchWithFile(nsIFile *a
       app = (do_CreateInstance("@mozilla.org/file/local;1"));
       if (!app) return NS_ERROR_FAILURE;
       app->InitWithFSRef(&appFSRef);
     } else {
       return NS_ERROR_FAILURE;
     }
   }
   nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(aFile);
-  return app->LaunchWithDoc(localFile, PR_FALSE); 
+  return app->LaunchWithDoc(localFile, PR_FALSE);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 nsresult 
 nsMIMEInfoMac::LoadUriInternal(nsIURI *aURI)
 {
   NS_ENSURE_ARG_POINTER(aURI);
   nsresult rv = NS_ERROR_FAILURE;
   
--- a/uriloader/exthandler/mac/nsOSHelperAppService.mm
+++ b/uriloader/exthandler/mac/nsOSHelperAppService.mm
@@ -35,33 +35,34 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsOSHelperAppService.h"
+#include "nsObjCExceptions.h"
 #include "nsISupports.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsXPIDLString.h"
 #include "nsIURL.h"
 #include "nsILocalFile.h"
 #include "nsILocalFileMac.h"
 #include "nsMimeTypes.h"
 #include "nsIStringBundle.h"
 #include "nsIPromptService.h"
 #include "nsMemory.h"
 #include "nsCRT.h"
 #include "nsMIMEInfoMac.h"
-
 #include "nsIInternetConfigService.h"
 #include "nsEmbedCID.h"
-#include <LaunchServices.h>
+
+#import <Carbon/Carbon.h>
 
 // chrome URL's
 #define HELPERAPPLAUNCHER_BUNDLE_URL "chrome://global/locale/helperAppLauncher.properties"
 #define BRAND_BUNDLE_URL "chrome://branding/locale/brand.properties"
 
 extern "C" {
   // Returns the CFURL for application currently set as the default opener for
   // the given URL scheme. appURL must be released by the caller.
@@ -100,16 +101,18 @@ nsresult nsOSHelperAppService::OSProtoco
       // or just provide the user with options for fixing it manually).
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsAString& _retval)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult rv = NS_ERROR_NOT_AVAILABLE;
 
   CFStringRef schemeCFString = 
     ::CFStringCreateWithBytes(kCFAllocatorDefault,
                               (const UInt8 *)PromiseFlatCString(aScheme).get(),
                               aScheme.Length(),
                               kCFStringEncodingUTF8,
                               false);
@@ -141,20 +144,24 @@ NS_IMETHODIMP nsOSHelperAppService::GetA
 
       ::CFRelease(handlerBundleURL);
     }
 
     ::CFRelease(schemeCFString);
   }
 
   return rv;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * aPlatformAppPath, nsIFile ** aFile)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
   nsresult rv;
   nsCOMPtr<nsILocalFileMac> localFile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv,rv);
 
   CFURLRef pathAsCFURL;
   CFStringRef pathAsCFString = ::CFStringCreateWithCharacters(NULL,
                                                               aPlatformAppPath,
                                                               nsCRT::strlen(aPlatformAppPath));
@@ -195,16 +202,18 @@ nsresult nsOSHelperAppService::GetFileTo
   ::CFRelease(pathAsCFString);
   ::CFRelease(pathAsCFURL);
   if (NS_FAILED(rv))
     return rv;
   *aFile = localFile;
   NS_IF_ADDREF(*aFile);
 
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 ///////////////////////////
 // method overrides --> use internet config information for mime type lookup.
 ///////////////////////////
 
 NS_IMETHODIMP nsOSHelperAppService::GetFromTypeAndExtension(const nsACString& aType, const nsACString& aFileExt, nsIMIMEInfo ** aMIMEInfo)
 {
   // first, ask our base class....
@@ -216,16 +225,18 @@ NS_IMETHODIMP nsOSHelperAppService::GetF
   return rv;
 }
 
 already_AddRefed<nsIMIMEInfo>
 nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType,
                                         const nsACString& aFileExt,
                                         PRBool * aFound)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSNULL;
+
   nsIMIMEInfo* mimeInfo = nsnull;
   *aFound = PR_TRUE;
 
   const nsCString& flatType = PromiseFlatCString(aMIMEType);
   const nsCString& flatExt = PromiseFlatCString(aFileExt);
 
   // ask the internet config service to look it up for us...
   nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
@@ -311,16 +322,18 @@ nsOSHelperAppService::GetMIMEInfoFromOS(
       // Just leave the default application unset.
       PR_LOG(mLog, PR_LOG_DEBUG, ("LSGetApplicationForInfo returned error code %d; default application was not set\n", err));
     }
     mimeInfo = mimeInfoMac;
     ::CFRelease(CFExt);
   }
   
   return mimeInfo;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSNULL;
 }
 
 NS_IMETHODIMP
 nsOSHelperAppService::GetProtocolHandlerInfoFromOS(const nsACString &aScheme,
                                                    PRBool *found,
                                                    nsIHandlerInfo **_retval)
 {
   NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");