Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Fixed a leak of AFHTTPRequestOperation in setCompletionBlock: #302

Merged

Conversation

kirsplatrick
Copy link
Contributor

This is to fix a leak that was introduced when I submitted the pull request #288. The setCompletionBlock: method was creating a retain cycle for the operation and so the operation was never being deallocated.

The way this was fixed was to add a reference to self that is declared as __block variabel so that it would not be retained by the block. Also a local reference to the _onceToken was made since accessing an instance variable by reference within a block also retains self.

Credit goes to @note173 who found the issue (#301) and proposed the fix that is in this pull request.

- Added a block object to reference self in the completion block
- Added a pointer to the onceToken to be used in the completion block
@mattt
Copy link
Contributor

mattt commented Apr 15, 2012

Huh, yeah, that would do it. Thanks for the patch, and thanks to @note173 for spotting the issue.

mattt pushed a commit that referenced this pull request Apr 15, 2012
…-fix

Fixed a leak of AFHTTPRequestOperation in setCompletionBlock:
@mattt mattt merged commit c4b5772 into AFNetworking:master Apr 15, 2012
greghe pushed a commit to skillz/AFNetworking that referenced this pull request Sep 3, 2015
…eration-leak-fix

Fixed a leak of AFHTTPRequestOperation in setCompletionBlock:
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants