From 64c401b5d8d1fe5f8b73917556823dbff55260ff Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Tue, 28 Jun 2016 19:31:55 -0700 Subject: [PATCH] Fixed a memory leak which would occur on every application switch. --- ThirdParty/SPMediaKeyTap/SPMediaKeyTap.m | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ThirdParty/SPMediaKeyTap/SPMediaKeyTap.m b/ThirdParty/SPMediaKeyTap/SPMediaKeyTap.m index b46edb239..d6d5d6ee9 100644 --- a/ThirdParty/SPMediaKeyTap/SPMediaKeyTap.m +++ b/ThirdParty/SPMediaKeyTap/SPMediaKeyTap.m @@ -271,12 +271,18 @@ NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys"; -(void)appIsNowFrontmost:(ProcessSerialNumber)psn; { NSValue *psnv = [NSValue valueWithBytes:&psn objCType:@encode(ProcessSerialNumber)]; - - NSDictionary *processInfo = (__bridge id)ProcessInformationCopyDictionary( - &psn, - kProcessDictionaryIncludeAllInformationMask - ); + + CFDictionaryRef cfDict = ProcessInformationCopyDictionary( + &psn, + kProcessDictionaryIncludeAllInformationMask + ); + + if (!cfDict) return; + + NSDictionary *processInfo = (__bridge id)cfDict; NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey]; + + CFRelease(cfDict); NSArray *whitelistIdentifiers = [[NSUserDefaults standardUserDefaults] arrayForKey:kMediaKeyUsingBundleIdentifiersDefaultsKey]; if(![whitelistIdentifiers containsObject:bundleIdentifier]) return;