Skip to content

Commit

Permalink
Fix a race condition in debug code that could lead to accessing a fre…
Browse files Browse the repository at this point in the history
…ed object
  • Loading branch information
dmoagx committed Mar 10, 2017
1 parent 7c56b11 commit cbfadab
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ - (void)_keepAlive
*/
- (void)_threadedKeepAlive
{
if(keepAliveThread) {
NSLog(@"warning: overwriting existing keepAliveThread: %@, results may be unpredictable!",keepAliveThread);
@synchronized(self) {
if(keepAliveThread) {
NSLog(@"warning: overwriting existing keepAliveThread: %@, results may be unpredictable!",keepAliveThread);
}
}

keepAliveThread = [NSThread currentThread];
Expand Down Expand Up @@ -114,7 +116,9 @@ - (void)_threadedKeepAlive
keepAlivePingFailures++;
}
end_cleanup:
keepAliveThread = nil;
@synchronized(self) {
keepAliveThread = nil;
}
}

#pragma mark -
Expand Down

0 comments on commit cbfadab

Please sign in to comment.