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.
main
Sam Lantinga 2014-06-15 17:18:05 -07:00
parent 54771080f3
commit 6146fe85cc
1 changed files with 3 additions and 3 deletions

View File

@ -200,14 +200,14 @@ Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist)
static const char * static const char *
Cocoa_GetDisplayName(CGDirectDisplayID displayID) Cocoa_GetDisplayName(CGDirectDisplayID displayID)
{ {
NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName); CFDictionaryRef deviceInfo = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName);
NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; NSDictionary *localizedNames = [(NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
const char* displayName = NULL; const char* displayName = NULL;
if ([localizedNames count] > 0) { if ([localizedNames count] > 0) {
displayName = SDL_strdup([[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String]); displayName = SDL_strdup([[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String]);
} }
[deviceInfo release]; CFRelease(deviceInfo);
return displayName; return displayName;
} }