Skip to content

Commit

Permalink
Fixed 2584 - Memory leak in Cocoa_GetDisplayName
Browse files Browse the repository at this point in the history
Diego

The Xcode Instruments Leak tool reports a leak from IODisplayCreateInfoDictionary in Cocoa_GetDisplayName.
This happened after upgrading to Xcode 5.
  • Loading branch information
slouken committed Jun 16, 2014
1 parent 5477108 commit 6146fe8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/video/cocoa/SDL_cocoamodes.m
Expand Up @@ -200,14 +200,14 @@
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;
}

Expand Down

0 comments on commit 6146fe8

Please sign in to comment.