From 90dea92e8c20e9ca321e2f7d57ad37a3fb2d4203 Mon Sep 17 00:00:00 2001 From: Luca Severini Date: Sun, 8 Nov 2015 11:58:23 -0800 Subject: [PATCH] Update Reachability.m The changes fix the leak reported by the Analyzer in XCode 7. Issue #114 --- Reachability.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Reachability.m b/Reachability.m index 4c1c94a..46d027b 100644 --- a/Reachability.m +++ b/Reachability.m @@ -98,8 +98,9 @@ +(instancetype)reachabilityWithHostname:(NSString*)hostname SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]); if (ref) { - id reachability = [[self alloc] initWithReachabilityRef:ref]; - + id reachability = [[self alloc] initWithReachabilityRef:CFBridgingRetain((__bridge id)ref)]; + CFRelease(ref); + return reachability; } @@ -111,7 +112,8 @@ +(instancetype)reachabilityWithAddress:(void *)hostAddress SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress); if (ref) { - id reachability = [[self alloc] initWithReachabilityRef:ref]; + id reachability = [[self alloc] initWithReachabilityRef:CFBridgingRetain((__bridge id)ref)]; + CFRelease(ref); return reachability; }