From ee3edc07596a5f2921b890103546129a5fefd1ef Mon Sep 17 00:00:00 2001 From: Javier Soto Date: Thu, 11 Oct 2012 13:19:04 -0700 Subject: [PATCH] Fixing very obvious wrong behaviour when cleaning up the blocks. There was a code added to make sure that the blocks were deallocated on the main thread, and it was wrong (it was over-releasing an NSMutableArray). Somebody fixed it by removing the second release, which is the wrong fix. There's an obvious code smell seeing how there's a performSelector: to a method that does nothing.... This is one of the thounsands of wrong things in ASIHTTPRequest, specially in memory management, I strongly recomment to all the folks out there that you migrate to AFNetworking, but I'm pushing the pull request in case somebody is getting crashes from this. --- Classes/ASIHTTPRequest.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/ASIHTTPRequest.m b/Classes/ASIHTTPRequest.m index 8dd162c3..ceb46b2f 100644 --- a/Classes/ASIHTTPRequest.m +++ b/Classes/ASIHTTPRequest.m @@ -404,7 +404,7 @@ - (void)dealloc #if NS_BLOCKS_AVAILABLE - (void)releaseBlocksOnMainThread { - NSMutableArray *blocks = [NSMutableArray array]; + NSMutableArray *blocks = [[NSMutableArray alloc] init]; if (completionBlock) { [blocks addObject:completionBlock]; [completionBlock release]; @@ -471,6 +471,7 @@ - (void)releaseBlocksOnMainThread + (void)releaseBlocks:(NSArray *)blocks { // Blocks will be released when this method exits + [blocks release]; } #endif