From e7e63fd4092a81beec482fc48d05f1a048801037 Mon Sep 17 00:00:00 2001 From: Mehdi Mulani Date: Tue, 2 Oct 2018 13:53:09 -0700 Subject: [PATCH] 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 --- Libraries/Network/RCTNetInfo.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Libraries/Network/RCTNetInfo.m b/Libraries/Network/RCTNetInfo.m index 0b3578fe0..715bfc3ad 100644 --- a/Libraries/Network/RCTNetInfo.m +++ b/Libraries/Network/RCTNetInfo.m @@ -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");