Skip to content

Commit

Permalink
Dealloc first time RCTNetInfo reachability callback
Browse files Browse the repository at this point in the history
Summary:
@public
We're seeing a crasher where `self` on line 54 isn't an `RCTNetInfo`. The timing looks related to D9798488, so my theory is that this class is being deallocated before it resolves, and thus causes a crash.

Reviewed By: PeteTheHeat

Differential Revision: D10127341

fbshipit-source-id: 94eaba7def6b118092adcf6b4cce841ccc7d0b59
  • Loading branch information
Mehdi Mulani authored and facebook-github-bot committed Oct 2, 2018
1 parent 408207b commit e7e63fd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Libraries/Network/RCTNetInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ - (void)stopObserving
}
}

- (void)dealloc
{
if (_firstTimeReachability) {
SCNetworkReachabilityUnscheduleFromRunLoop(self->_firstTimeReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
CFRelease(self->_firstTimeReachability);
}
}

- (SCNetworkReachabilityRef)getReachabilityRef
{
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, _host.UTF8String ?: "apple.com");
Expand Down

0 comments on commit e7e63fd

Please sign in to comment.