Re: [AD] r14283 Fix some leaks in new(er) osx joystick code

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Tue, Jan 18, 2011 at 9:06 PM, Trent Gamblin <trent@xxxxxxxxxx> wrote:
> Yes. Though the fixes that I left in do fix the joystick leaks.
Oh yes, I agree.
Attached is everything the XCode analyzer and clang 2.9 came up with
(patch against current 5.1 SVN)

Pete
Index: src/macosx/hidman.m
===================================================================
--- src/macosx/hidman.m	(revision 14289)
+++ src/macosx/hidman.m	(working copy)
@@ -450,8 +450,8 @@
 			}
 			IOObjectRelease(hid_object_iterator);
 		}
-		CFRelease(usage_ref);
-		CFRelease(usage_page_ref);
+		if (usage_ref) CFRelease(usage_ref);
+		if (usage_page_ref) CFRelease(usage_page_ref);
 		mach_port_deallocate(mach_task_self(), master_port);
 	}
 	
Index: src/macosx/osx_app_delegate.m
===================================================================
--- src/macosx/osx_app_delegate.m	(revision 14289)
+++ src/macosx/osx_app_delegate.m	(working copy)
@@ -254,10 +254,10 @@
 
 /* Helper macro to add entries to the menu */
 #define add_menu(name, sel, eq)                                         \
-        [menu addItem: [[NSMenuItem allocWithZone: [NSMenu menuZone]]   \
+        [menu addItem: [[[NSMenuItem allocWithZone: [NSMenu menuZone]]   \
                                     initWithTitle: name                 \
                                            action: @selector(sel)       \
-                                    keyEquivalent: eq]]                 \
+                                    keyEquivalent: eq] autorelease]]                 \
 
 int _al_osx_run_main(int argc, char **argv,
    int (*real_main)(int, char **))
Index: addons/image/macosx.m
===================================================================
--- addons/image/macosx.m	(revision 14289)
+++ addons/image/macosx.m	(working copy)
@@ -36,8 +36,10 @@
    // CGImageForProposedRect...
    //CGImageRef cgimage = [image_rep CGImageForProposedRect: nil context: nil hints: nil];
    
-   if (!image_rep) 
+   if (!image_rep) {
+	  [image release];
       return NULL;
+   }
 
    /* Get the actual size in pixels from the representation */
    int w = [image_rep pixelsWide];
@@ -206,8 +208,6 @@
    size_t size = (size_t)[nsdata length];
    bool ret = al_fwrite(f, [nsdata bytes], size) == size;
    
-   [nsdata release];
-   [reps release];
    [image release];
    
    return ret;
Index: addons/native_dialog/osx_dialog.m
===================================================================
--- addons/native_dialog/osx_dialog.m	(revision 14289)
+++ addons/native_dialog/osx_dialog.m	(working copy)
@@ -284,6 +284,7 @@
    [scrollView setDocumentView: view];
    
    [[win contentView] addSubview: scrollView];
+   [scrollView release];
    
    [win setDelegate: view];
    [win orderFront: nil];


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/