Skip to content

Commit

Permalink
Fixed potential crash on reachability status check
Browse files Browse the repository at this point in the history
  • Loading branch information
belkevich committed Jan 16, 2016
1 parent 6115225 commit 5a12ccd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Classes/Public/SCNetworkReachability.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ @interface SCNetworkReachability ()

@property (atomic, assign) BOOL isStatusValid;
@property (atomic, assign) SCNetworkStatus status;
@property (atomic, copy) void (^statusBlock)(SCNetworkStatus status);
@property (nonatomic, copy) void (^observationBlock)(SCNetworkStatus status);
@property (nonatomic, copy) void (^statusBlock)(SCNetworkStatus status);
@end

@implementation SCNetworkReachability
Expand Down Expand Up @@ -111,7 +111,8 @@ - (void)reachabilityStatusOnDispatchQueue:(dispatch_queue_t)queue
[self updateStatusBlockWithDispatchQueue:queue block:block];
if (self.isStatusValid)
{
self.statusBlock(self.status);
safe_block(self.statusBlock, self.status);
self.statusBlock = nil;
}
}
}
Expand All @@ -136,7 +137,7 @@ - (void)updateStatusBlockWithDispatchQueue:(dispatch_queue_t)queue
{
if (self.statusBlock)
{
void (^previousBlock)(SCNetworkStatus status) = self.statusBlock;
void (^previousBlock)(SCNetworkStatus) = self.statusBlock;
self.statusBlock = ^(SCNetworkStatus status)
{
previousBlock(status);
Expand Down

0 comments on commit 5a12ccd

Please sign in to comment.