Changeset 3794

Show
Ignore:
Timestamp:
07/18/08 17:42:24 (4 months ago)
Author:
timothy
Message:

Fix the real leaks found by the clang static analyzer. #1260

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Additions/NSNotificationAdditions.m

    r3729 r3794  
    3030        if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:userInfo]; 
    3131 
     32        // The info dictionary is released in _postNotificationName. 
    3233        NSMutableDictionary *info = [[NSMutableDictionary allocWithZone:nil] initWithCapacity:3]; 
    3334        if( name ) [info setObject:name forKey:@"name"]; 
     
    4546        [[self defaultCenter] postNotificationName:name object:object userInfo:userInfo]; 
    4647 
    47         [info release]; 
     48        [info release]; // Balance the alloc in postNotificationOnMainThreadWithName. 
    4849} 
    4950@end 
  • trunk/Chat Core/MVIRCChatConnection.m

    r3790 r3794  
    647647                CFReadStreamSetProperty( [sock getCFReadStream], kCFStreamPropertySSLSettings, (CFDictionaryRef) settings ); 
    648648                CFWriteStreamSetProperty( [sock getCFWriteStream], kCFStreamPropertySSLSettings, (CFDictionaryRef) settings ); 
     649 
     650                [settings release]; 
    649651        } 
    650652 
     
    20432045        MVAssertCorrectThreadRequired( _connectionThread ); 
    20442046 
     2047        // The info dictionary is released in _handleCTCP:. 
    20452048        NSMutableDictionary *info = [[NSMutableDictionary allocWithZone:nil] initWithCapacity:4]; 
    20462049        if( data ) [info setObject:data forKey:@"data"]; 
     
    20632066 
    20642067                if( [sender isLocalUser] ) { 
     2068                        // The room is released in _handle366WithParameters. 
    20652069                        if( ! room ) { 
    20662070                                room = [[MVIRCChatRoom allocWithZone:nil] initWithName:name andConnection:self]; 
  • trunk/Chat Core/MVSILCChatConnection.m

    r3763 r3794  
    5656        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomBannedUsersSyncedNotification object:room userInfo:nil]; 
    5757 
    58         [room release]; 
     58        [room release]; // Balance the retain in silc_command_reply (case SILC_COMMAND_JOIN). 
    5959} 
    6060 
     
    629629                /* SilcUInt32 user_limit = */ va_arg( list, SilcUInt32 ); 
    630630 
     631                // The room is released in silc_channel_get_clients_per_list_callback. 
    631632                MVSILCChatRoom *room = (MVSILCChatRoom *)[self joinedChatRoomWithChannel:channel]; 
    632633                if( ! room ) { 
     
    728729        void *completionContext = SILC_32_TO_PTR( [(NSNumber *)[dict objectForKey:@"context"] unsignedIntValue] ); 
    729730 
    730         [dict release]; // was retained earlier in silc_get_auth_method 
    731         dict = nil; 
    732  
    733731        switch( auth_method ) { 
    734732        case SILC_AUTH_NONE: 
     
    747745                break; 
    748746        } 
     747 
     748        [dict release]; // Balance the alloc in silc_get_auth_method. 
    749749} 
    750750 
    751751static void silc_get_auth_method( SilcClient client, SilcClientConnection conn, char *hostname, SilcUInt16 port, SilcGetAuthMeth completion, void *context ) { 
     752        // The dictionary is released in silc_get_auth_method_callback. 
    752753        NSDictionary *dict = [[NSDictionary allocWithZone:nil] initWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:SILC_PTR_TO_32( completion )], @"completion", [NSNumber numberWithUnsignedInt:SILC_PTR_TO_32( context )], @"context", nil]; 
    753754        silc_client_request_authentication_method( client, conn, silc_get_auth_method_callback, dict ); 
     
    835836 
    836837        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionNeedPublicKeyVerificationNotification object:self userInfo:dict]; 
     838 
     839        [dict release]; 
    837840} 
    838841 
  • trunk/Chat Core/MVSILCFileTransfer.m

    r3420 r3794  
    118118                        if( error != SILC_CLIENT_FILE_OK ) { 
    119119                                [transfer _silcPostError:error]; 
     120                                [transfer release]; 
    120121                                SilcUnlock( [[user connection] _silcClient] ); 
    121122                                return nil; 
     
    128129        } else return nil; 
    129130 
    130         return transfer
     131        return [transfer autorelease]
    131132} 
    132133 
  • trunk/Chat Core/MVXMPPChatConnection.m

    r3722 r3794  
    388388        if ([[presence getAttribute:@"type"] isCaseInsensitiveEqualToString:@"error"]) { 
    389389                [self _removeJoinedRoom:room]; 
    390                 [room release]; 
     390                [room release]; // balance the alloc or retain in joinChatRoomNamed: 
    391391                // handle error... 
    392392                return; 
  • trunk/Controllers/MVBuddyListController.m

    r3607 r3794  
    331331 
    332332        [buddy addWatchRule:rule]; 
     333        [rule release]; 
    333334 
    334335        [self addBuddy:buddy]; 
     336        [buddy release]; 
     337 
    335338        [self save]; 
    336339 
  • trunk/Controllers/MVConnectionsController.m

    r3763 r3794  
    3737#pragma mark - 
    3838 
    39 @interface NSDisclosureButtonCell 
     39@interface NSDisclosureButtonCell : NSCell 
    4040+ (id) alloc; 
    4141- (id) initWithCell:(NSCell *) cell; 
     
    214214        [toolbar setAutosavesConfiguration:YES]; 
    215215        [[self window] setToolbar:toolbar]; 
    216          
    217         [showDetails setCell:[[NSDisclosureButtonCell alloc] initWithCell:[showDetails cell]]]; 
     216 
     217        NSDisclosureButtonCell *cell = [[NSDisclosureButtonCell alloc] initWithCell:[showDetails cell]]; 
     218        [showDetails setCell:cell]; 
     219        [cell release]; 
    218220 
    219221        [self setWindowFrameAutosaveName:@"Connections"]; 
  • trunk/Controllers/MVCrashCatcher.m

    r3763 r3794  
    66        if( [[NSBundle bundleWithIdentifier:@"com.unsanity.smartcrashreports"] isLoaded] ) 
    77                return; // user has Unsanity Smart Crash Reports installed, don't use our own reporter 
    8         [[MVCrashCatcher alloc] init]; 
     8        [[MVCrashCatcher alloc] init]; // Released when the window is closed. 
    99} 
    1010 
  • trunk/Frameworks/Acid/jabber/Jabber.m

    r3640 r3794  
    4343+(void) load 
    4444{ 
    45     [[NSAutoreleasePool alloc] init]; 
     45       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    4646 
    4747    // Setup QNames 
     
    6262    [XMLElementStream registerElementFactory:[JabberMessage class]]; 
    6363    [XMLElementStream registerElementFactory:[JabberSubscriptionRequest class]]; 
     64 
     65        [pool drain]; 
    6466} 
    6567 
  • trunk/Frameworks/Acid/jabber/JabberSocket.m

    r3764 r3794  
    111111                CFReadStreamSetProperty( [sock getCFReadStream], kCFStreamPropertySSLSettings, (CFDictionaryRef) settings ); 
    112112                CFWriteStreamSetProperty( [sock getCFWriteStream], kCFStreamPropertySSLSettings, (CFDictionaryRef) settings ); 
     113 
     114                [settings release]; 
    113115        } 
    114116 
  • trunk/Panels/JVDirectChatPanel.m

    r3790 r3794  
    231231                                [[self transcript] setFilePath:logs]; 
    232232                                [[self transcript] setSource:source]; 
    233                                 [source release]; 
    234233                                [[self transcript] setAutomaticallyWritesChangesToFile:YES]; 
    235234                        } 
     235 
     236                        [source release]; 
    236237 
    237238                        [[self transcript] setElementLimit:0]; // start with zero limit 
     
    841842        if( ! [messageString length] && [cmessage ignoreStatus] == JVNotIgnored ) {  // plugins decided to excluded this message, decrease the new message counts 
    842843                _newMessageCount--; 
     844                [cmessage release]; 
    843845                return; 
    844846        } 
     
    13831385 
    13841386                [toolbarItem setToolTip:NSLocalizedString( @"Text Encoding Options", "encoding menu toolbar item tooltip" )]; 
    1385                 [toolbarItem setView:button]; 
    13861387                [toolbarItem setMinSize:NSMakeSize( 60., 24. )]; 
    13871388                [toolbarItem setMaxSize:NSMakeSize( 60., 32. )]; 
     1389 
     1390                [toolbarItem setView:button]; 
     1391                [button release]; 
    13881392 
    13891393                NSMenuItem *menuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Encoding", "encoding menu toolbar item" ) action:NULL keyEquivalent:@""] autorelease]; 
  • trunk/Views/MVTextView.m

    r3770 r3794  
    3737 
    3838        if( ! [self isEditable] ) { 
     39                [newArray release]; 
    3940                [super interpretKeyEvents:eventArray]; 
    4041                return;