From c3cac2c620f188e259d3e99d5db7952ff5345f05 Mon Sep 17 00:00:00 2001 From: Steven Michaud Date: Tue, 9 Mar 2010 10:37:56 -0600 Subject: [PATCH] Bug 541809 - Firefox autoreleasing objects without pool in place. r=josh,jfkthame --- gfx/thebes/src/gfxMacPlatformFontList.mm | 28 +++++++++++++++++++ .../exthandler/mac/nsOSHelperAppService.mm | 4 +++ 2 files changed, 32 insertions(+) diff --git a/gfx/thebes/src/gfxMacPlatformFontList.mm b/gfx/thebes/src/gfxMacPlatformFontList.mm index 8e00cc6100e8..94f6a78feb8a 100644 --- a/gfx/thebes/src/gfxMacPlatformFontList.mm +++ b/gfx/thebes/src/gfxMacPlatformFontList.mm @@ -56,6 +56,20 @@ #include #include +class nsAutoreleasePool { +public: + nsAutoreleasePool() + { + mLocalPool = [[NSAutoreleasePool alloc] init]; + } + ~nsAutoreleasePool() + { + [mLocalPool release]; + } +private: + NSAutoreleasePool *mLocalPool; +}; + // font info loader constants static const PRUint32 kDelayBeforeLoadingCmaps = 8 * 1000; // 8secs static const PRUint32 kIntervalBetweenLoadingCmaps = 150; // 150ms @@ -274,6 +288,8 @@ MacOSFontEntry::ReadCMAP() nsresult MacOSFontEntry::GetFontTable(PRUint32 aTableTag, nsTArray& aBuffer) { + nsAutoreleasePool localPool; + ATSFontRef fontRef = GetFontRef(); if (fontRef == (ATSFontRef)kATSUInvalidFontID) return NS_ERROR_FAILURE; @@ -321,6 +337,8 @@ public: void gfxMacFontFamily::LocalizedName(nsAString& aLocalizedName) { + nsAutoreleasePool localPool; + if (!HasOtherFamilyNames()) { aLocalizedName = mName; return; @@ -346,6 +364,8 @@ gfxMacFontFamily::FindStyleVariations() if (mHasStyles) return; + nsAutoreleasePool localPool; + NSString *family = GetNSStringForString(mName); // create a font entry for each face @@ -502,6 +522,8 @@ public: void gfxSingleFaceMacFontFamily::LocalizedName(nsAString& aLocalizedName) { + nsAutoreleasePool localPool; + if (!HasOtherFamilyNames()) { aLocalizedName = mName; return; @@ -567,6 +589,8 @@ gfxMacPlatformFontList::gfxMacPlatformFontList() : void gfxMacPlatformFontList::InitFontList() { + nsAutoreleasePool localPool; + ATSGeneration currentGeneration = ::ATSGetGeneration(); // need to ignore notifications after adding each font @@ -730,6 +754,8 @@ gfxMacPlatformFontList::ATSNotification(ATSFontNotificationInfoRef aInfo, gfxFontEntry* gfxMacPlatformFontList::GetDefaultFont(const gfxFontStyle* aStyle, PRBool& aNeedsBold) { + nsAutoreleasePool localPool; + NSString *defaultFamily = [[NSFont userFontOfSize:aStyle->size] familyName]; nsAutoString familyName; @@ -751,6 +777,8 @@ gfxFontEntry* gfxMacPlatformFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry, const nsAString& aFontName) { + nsAutoreleasePool localPool; + NSString *faceName = GetNSStringForString(aFontName); // first lookup a single face based on postscript name diff --git a/uriloader/exthandler/mac/nsOSHelperAppService.mm b/uriloader/exthandler/mac/nsOSHelperAppService.mm index 3ecc9341ab8c..b3f429911046 100644 --- a/uriloader/exthandler/mac/nsOSHelperAppService.mm +++ b/uriloader/exthandler/mac/nsOSHelperAppService.mm @@ -257,6 +257,8 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType, return nsnull; NS_ADDREF(mimeInfoMac); + NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init]; + OSStatus err; PRBool haveAppForType = PR_FALSE; PRBool haveAppForExt = PR_FALSE; @@ -349,6 +351,7 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType, nsCOMPtr app(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID)); if (!app) { NS_RELEASE(mimeInfoMac); + [localPool release]; return nsnull; } @@ -413,6 +416,7 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType, PR_LOG(mLog, PR_LOG_DEBUG, ("OS gave us: type '%s' found '%i'\n", mimeType.get(), *aFound)); + [localPool release]; return mimeInfoMac; NS_OBJC_END_TRY_ABORT_BLOCK_NSNULL;