Changeset 68

Show
Ignore:
Timestamp:
12/27/05 14:14:42 (3 years ago)
Author:
mrowe
Message:

Manage the NSMutableArray of paths better to prevent it from leaking, and use a more idiomatic iteration style to populate it. Closes #29.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Libs/SSHKeychain.m

    r41 r68  
    249249- (BOOL)addKeysToAgentWithInteraction:(BOOL)interaction 
    250250{ 
    251         NSMutableArray *paths; 
     251        NSMutableArray *paths = [NSMutableArray array]; 
     252        NSString *path; 
     253        NSEnumerator *e; 
    252254        SSHTool *theTool; 
    253         int i, ts; 
    254  
    255         paths = [[self arrayOfPaths] mutableCopy]; 
     255        int ts; 
    256256 
    257257        if([self addingKeys]) 
     
    265265        } 
    266266         
    267         for(i=0; i < [paths count]; i++) { 
    268                if([[NSFileManager defaultManager] isReadableFileAtPath:[paths objectAtIndex:i]] == NO) { 
    269                        [paths removeObjectAtIndex:i]; 
    270                        i--; 
    271                 } 
     267        e = [[self arrayOfPaths] objectEnumerator]; 
     268        while (path = [e nextObject]) 
     269        { 
     270                if ([[NSFileManager defaultManager] isReadableFileAtPath:path]) 
     271                       [paths addObject:path]; 
    272272        } 
    273273                 
     
    283283        theTool =  [SSHTool toolWithName:@"ssh-add"]; 
    284284 
    285         /* Set the SSH_ASKPASS + DISPLAY environment variables, so the tool can ask for a passphrase. */ 
     285       /* Set the SSH_ASKPASS + DISPLAY environment variables, so the tool can ask for a passphrase. */ 
    286286        [theTool setEnvironmentVariable:@"SSH_ASKPASS" withValue: 
    287287                [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"PassphraseRequester"]];