From 328636c6d630aaeba89bc8b731cb6874f78ae033 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 14 Apr 2011 14:27:02 -0700 Subject: [PATCH] Fix for defect reported by danielrhodes If a handler has a retain count of 1 and gets released after finishing a download (by being bumped from the buffer), it causes a crash when it tries to add itself to the memory buffer. This would occur at line 355 in HJMOHandler.m. I think this can be solved by bumping it from the download buffer after the object has been added to the memory buffe Signed-off-by: Mark Johnson --- HJCacheClasses/HJMOHandler.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HJCacheClasses/HJMOHandler.m b/HJCacheClasses/HJMOHandler.m index c95f9a1..fb8643e 100755 --- a/HJCacheClasses/HJMOHandler.m +++ b/HJCacheClasses/HJMOHandler.m @@ -333,6 +333,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { + [self retain]; //ensure that self isn't released in this method when the connection is finished with it. //NSLog(@"finishedLoading %@",self); state = stateLoaded; if (moLoadingDataFile) { @@ -356,6 +357,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection { if (state==stateReady || state==stateLoaded) { [objManager addHandlerToMemCache:self]; } + [self release]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {