Skip to content

Commit

Permalink
Fix for defect reported by danielrhodes
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
markofjohnson committed Apr 14, 2011
1 parent 350745b commit 328636c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions HJCacheClasses/HJMOHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down

0 comments on commit 328636c

Please sign in to comment.