]> git.sesse.net Git - vlc/commitdiff
macosx: fix longstanding ~30KB memory leak in the AppleRemote wrapper
authorFelix Paul Kühne <fkuehne@videolan.org>
Thu, 2 May 2013 14:10:04 +0000 (15:10 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Thu, 2 May 2013 14:10:25 +0000 (15:10 +0100)
modules/gui/macosx/AppleRemote.m

index 1a8e113d53341470fb746d4a4d143f4ed488fd3b..b526a60f7ca5d75f9fc59550132b48d6174271e3 100644 (file)
@@ -544,7 +544,7 @@ static void QueueCallbackFunction(void* target,  IOReturn result, void* refcon,
     long                    usage;
     long                    usagePage;
     id                      object;
-    NSArray*                elements = nil;
+    NSArray*                elements;
     NSDictionary*           element;
     IOReturn success;
 
@@ -557,8 +557,6 @@ static void QueueCallbackFunction(void* target,  IOReturn result, void* refcon,
     success = (*handle)->copyMatchingElements(handle, NULL, (CFArrayRef*)&elements);
 
     if (success == kIOReturnSuccess) {
-
-        [elements autorelease];
         /*
         cookies = calloc(NUMBER_OF_APPLE_REMOTE_ACTIONS, sizeof(IOHIDElementCookie));
         memset(cookies, 0, sizeof(IOHIDElementCookie) * NUMBER_OF_APPLE_REMOTE_ACTIONS);
@@ -588,7 +586,10 @@ static void QueueCallbackFunction(void* target,  IOReturn result, void* refcon,
         }
         _allCookies = [[NSArray alloc] initWithArray: mutableAllCookies];
         [mutableAllCookies release];
+        [elements release];
     } else {
+        if (elements)
+            [elements release];
         return NO;
     }