On Jan 29, 2009, at 12:20 PM, Mr. Gecko wrote:

[theTask setArguments:[[NSArray arrayWithObjects:@"-s", MD5, nil] autorelease]];

This is incorrect and should be causing a crash, unless you're using GC. +arrayWithObjects: already returns an autoreleased object.

NSString *rMD5 = [[[[NSString alloc] initWithData:[[outPipe fileHandleForReading] readDataToEndOfFile] encoding: NSUTF8StringEncoding] componentsSeparatedByString:@" = "] objectAtIndex:1];

Your memory leak is right here. The result of -initWithData: needs to be autoreleased. But I'd also recommend breaking up that line to be easier to read...

        rMD5 = [self replace:@"\n" with:@"" source:rMD5];
        
        return [rMD5 autorelease];


If your replace method isn't returning an autoreleased object, it should be. Don't break with conventions.

Also, if you want to hash something, then you should probably use the functions in libcrypto instead of using NSTask. That'll at least be faster...

Nick Zitzmann
<http://www.chronosnet.com/>



_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to