Dealloc first time RCTNetInfo reachability callback

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
This commit is contained in:
Mehdi Mulani
2018-10-02 13:53:09 -07:00
committed by Facebook Github Bot
parent 408207b356
commit e7e63fd409

View File

@@ -105,6 +105,14 @@ static void RCTReachabilityCallback(__unused SCNetworkReachabilityRef target, SC
}
}
- (void)dealloc
{
if (_firstTimeReachability) {
SCNetworkReachabilityUnscheduleFromRunLoop(self->_firstTimeReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
CFRelease(self->_firstTimeReachability);
}
}
- (SCNetworkReachabilityRef)getReachabilityRef
{
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, _host.UTF8String ?: "apple.com");