From 6146fe85cc7bc43bcf4883216411f7de7d4eccbc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 15 Jun 2014 17:18:05 -0700 Subject: [PATCH] Fixed 2584 - Memory leak in Cocoa_GetDisplayName Diego The Xcode Instruments Leak tool reports a leak from IODisplayCreateInfoDictionary in Cocoa_GetDisplayName. This happened after upgrading to Xcode 5. --- src/video/cocoa/SDL_cocoamodes.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index f41c34937..68a1cff01 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -200,14 +200,14 @@ Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist) static const char * Cocoa_GetDisplayName(CGDirectDisplayID displayID) { - NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName); - NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; + CFDictionaryRef deviceInfo = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName); + NSDictionary *localizedNames = [(NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; const char* displayName = NULL; if ([localizedNames count] > 0) { displayName = SDL_strdup([[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String]); } - [deviceInfo release]; + CFRelease(deviceInfo); return displayName; }