Fixed two CF memory leaks. (Fixes issue #5)
authorJens Alfke <jens@mooseyard.com>
Tue Apr 28 10:36:28 2009 -0700 (2009-04-28)
changeset 2959689fbdcf77
parent 28 732576fa8a0d
child 31 1d6924779df7
Fixed two CF memory leaks. (Fixes issue #5)
BLIP/BLIPTest.m
TCP/TCPConnection.m
     1.1 --- a/BLIP/BLIPTest.m	Mon Apr 27 09:03:56 2009 -0700
     1.2 +++ b/BLIP/BLIPTest.m	Tue Apr 28 10:36:28 2009 -0700
     1.3 @@ -52,6 +52,7 @@
     1.4      SecIdentityRef identity;
     1.5      while (SecIdentitySearchCopyNext(search, &identity) == noErr)
     1.6          [identities addObject: (id)identity];
     1.7 +    CFRelease(search);
     1.8      Log(@"Found %u identities -- prompting '%@'", identities.count, prompt);
     1.9      if (identities.count > 0) {
    1.10          SFChooseIdentityPanel *panel = [SFChooseIdentityPanel sharedChooseIdentityPanel];
     2.1 --- a/TCP/TCPConnection.m	Mon Apr 27 09:03:56 2009 -0700
     2.2 +++ b/TCP/TCPConnection.m	Tue Apr 28 10:36:28 2009 -0700
     2.3 @@ -111,14 +111,16 @@
     2.4      CFWriteStreamRef writeStream = NULL;
     2.5      CFStreamCreatePairWithSocket(kCFAllocatorDefault, socket, &readStream, &writeStream);
     2.6      self = [self _initWithAddress: [IPAddress addressOfSocket: socket] 
     2.7 -                      inputStream: (NSInputStream*)readStream
     2.8 -                     outputStream: (NSOutputStream*)writeStream];
     2.9 +                      inputStream: (NSInputStream*)CFMakeCollectable(readStream)
    2.10 +                     outputStream: (NSOutputStream*)CFMakeCollectable(writeStream)];
    2.11      if( self ) {
    2.12          _isIncoming = YES;
    2.13          _server = [listener retain];
    2.14          CFReadStreamSetProperty(readStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
    2.15          CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
    2.16      }
    2.17 +    if(readStream) CFRelease(readStream);
    2.18 +    if(writeStream) CFRelease(writeStream);
    2.19      return self;
    2.20  }    
    2.21