Fix a memory leak. We need to clean up our autorelease pool code at some point.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 12 Jan 2013 14:04:51 -0500
changeset 6809 54cca01b6006
parent 6808 3ad413bd1cd6
child 6810 b5609445aa4c
Fix a memory leak. We need to clean up our autorelease pool code at some point.
src/video/cocoa/SDL_cocoamodes.m
--- a/src/video/cocoa/SDL_cocoamodes.m	Fri Jan 11 20:36:39 2013 -0800
+++ b/src/video/cocoa/SDL_cocoamodes.m	Sat Jan 12 14:04:51 2013 -0500
@@ -235,6 +235,7 @@
 void
 Cocoa_InitModes(_THIS)
 {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     CGDisplayErr result;
     CGDirectDisplayID *displays;
     CGDisplayCount numDisplays;
@@ -243,6 +244,7 @@
     result = CGGetOnlineDisplayList(0, NULL, &numDisplays);
     if (result != kCGErrorSuccess) {
         CG_SetError("CGGetOnlineDisplayList()", result);
+        [pool release];
         return;
     }
     displays = SDL_stack_alloc(CGDirectDisplayID, numDisplays);
@@ -250,6 +252,7 @@
     if (result != kCGErrorSuccess) {
         CG_SetError("CGGetOnlineDisplayList()", result);
         SDL_stack_free(displays);
+        [pool release];
         return;
     }
 
@@ -313,6 +316,7 @@
         }
     }
     SDL_stack_free(displays);
+    [pool release];
 }
 
 int