Static analysis fix: leaking Objective-C object.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 20 Mar 2014 16:05:57 -0400
changeset 8653 b50c61457c91
parent 8652 8514fc57f124
child 8654 275c4c82803b
Static analysis fix: leaking Objective-C object.
src/video/cocoa/SDL_cocoaevents.m
--- a/src/video/cocoa/SDL_cocoaevents.m	Thu Mar 20 11:22:57 2014 -0400
+++ b/src/video/cocoa/SDL_cocoaevents.m	Thu Mar 20 16:05:57 2014 -0400
@@ -159,13 +159,19 @@
     NSMenu *windowMenu;
     NSMenu *viewMenu;
     NSMenuItem *menuItem;
+    NSMenu *mainMenu;
 
     if (NSApp == nil) {
         return;
     }
-    
+
+    mainMenu = [[NSMenu alloc] init];
+
     /* Create the main menu bar */
-    [NSApp setMainMenu:[[NSMenu alloc] init]];
+    [NSApp setMainMenu:mainMenu];
+
+    [mainMenu release];  /* we're done with it, let NSApp own it. */
+    mainMenu = nil;
 
     /* Create the application menu */
     appName = GetApplicationName();