From 755f913b0271b2ce54f5374e9b478a51d707ce29 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Mon, 28 Sep 2015 19:21:44 -0700 Subject: [PATCH] Fix invalid types, null pointer use, memory leak Closes #612. --- src/cocoa_window.m | 2 ++ src/iokit_joystick.m | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 54d528ae..b7486ad3 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -739,6 +739,7 @@ static void createMenuBar(void) [[appMenu addItemWithTitle:@"Services" action:NULL keyEquivalent:@""] setSubmenu:servicesMenu]; + [servicesMenu release]; [appMenu addItem:[NSMenuItem separatorItem]]; [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName] action:@selector(hide:) @@ -757,6 +758,7 @@ static void createMenuBar(void) NSMenuItem* windowMenuItem = [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""]; + [bar release]; NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; [NSApp setWindowsMenu:windowMenu]; [windowMenuItem setSubmenu:windowMenu]; diff --git a/src/iokit_joystick.m b/src/iokit_joystick.m index ebce5c8f..f21b2bf8 100644 --- a/src/iokit_joystick.m +++ b/src/iokit_joystick.m @@ -352,7 +352,7 @@ static CFMutableDictionaryRef createMatchingDictionary(long usagePage, if (result) { CFNumberRef pageRef = CFNumberCreate(kCFAllocatorDefault, - kCFNumberIntType, + kCFNumberLongType, &usagePage); if (pageRef) { @@ -362,7 +362,7 @@ static CFMutableDictionaryRef createMatchingDictionary(long usagePage, CFRelease(pageRef); CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, - kCFNumberIntType, + kCFNumberLongType, &usage); if (usageRef) { @@ -421,11 +421,11 @@ void _glfwInitJoysticks(void) CFArrayAppendValue(matchingCFArrayRef, matchingCFDictRef); CFRelease(matchingCFDictRef); } - } - IOHIDManagerSetDeviceMatchingMultiple(_glfw.iokit_js.managerRef, - matchingCFArrayRef); - CFRelease(matchingCFArrayRef); + IOHIDManagerSetDeviceMatchingMultiple(_glfw.iokit_js.managerRef, + matchingCFArrayRef); + CFRelease(matchingCFArrayRef); + } IOHIDManagerRegisterDeviceMatchingCallback(_glfw.iokit_js.managerRef, &matchCallback, NULL);