Bug 720168 - Crash in nsHttpChannel::CallOnStartRequest @ objc_msgSend | nsOSHelperAppService::GetMIMEInfoFromOS. r=bgirard
authorSteven Michaud <smichaud@pobox.com>
Mon, 23 Jan 2012 16:37:40 -0600
changeset 86371 8ec6ce57086f436d7a69bed30f3ee5177863afbe
parent 86370 f531dd09e05b36a12497727d7ef676d002ce2028
child 86372 1b2d36e0657b5cf7c151bd0bfa487ee18f3e8bf4
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgirard
bugs720168
milestone12.0a1
Bug 720168 - Crash in nsHttpChannel::CallOnStartRequest @ objc_msgSend | nsOSHelperAppService::GetMIMEInfoFromOS. r=bgirard
uriloader/exthandler/mac/nsOSHelperAppService.mm
--- a/uriloader/exthandler/mac/nsOSHelperAppService.mm
+++ b/uriloader/exthandler/mac/nsOSHelperAppService.mm
@@ -270,24 +270,25 @@ static CFArrayRef GetMIMETypesHandledByA
     return NULL;
   }
   CFDictionaryRef infoDict = ::CFBundleCopyInfoDictionaryForURL(appURL);
   ::CFRelease(appURL);
   if (!infoDict) {
     return NULL;
   }
   CFTypeRef cfObject = ::CFDictionaryGetValue(infoDict, CFSTR("CFBundleDocumentTypes"));
-  ::CFRelease(infoDict);
   if (!cfObject || (::CFGetTypeID(cfObject) != ::CFArrayGetTypeID())) {
+    ::CFRelease(infoDict);
     return NULL;
   }
 
   CFArrayRef docTypes = static_cast<CFArrayRef>(cfObject);
   CFIndex docTypesCount = ::CFArrayGetCount(docTypes);
   if (docTypesCount == 0) {
+    ::CFRelease(infoDict);
     return NULL;
   }
 
   CFMutableArrayRef mimeTypes =
     ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
   for (CFIndex i = 0; i < docTypesCount; ++i) {
     cfObject = ::CFArrayGetValueAtIndex(docTypes, i);
     if (!cfObject || (::CFGetTypeID(cfObject) != ::CFDictionaryGetTypeID())) {
@@ -307,16 +308,17 @@ static CFArrayRef GetMIMETypesHandledByA
     if (!cfObject || (::CFGetTypeID(cfObject) != ::CFArrayGetTypeID())) {
       continue;
     }
     CFArrayRef mimeTypeHolder = static_cast<CFArrayRef>(cfObject);
     CFArrayAppendArray(mimeTypes, mimeTypeHolder,
                        ::CFRangeMake(0, ::CFArrayGetCount(mimeTypeHolder)));
   }
 
+  ::CFRelease(infoDict);
   if (!::CFArrayGetCount(mimeTypes)) {
     ::CFRelease(mimeTypes);
     mimeTypes = NULL;
   }
   return mimeTypes;
 }
 
 // aMIMEType and aFileExt might not match,  If they don't we set *aFound to