Skip to content

Commit

Permalink
MRS-2850 Crash if listen/cancel is executed in quick succession
Browse files Browse the repository at this point in the history
The onDidAuthorizationChanged is executed by iOS somewhen afer CLLocationManager is created in onListenWithArguments.

If the the subscription is canceled in the meantime _eventSink (onCancelWithArguments) is set to nil leading to accessing _eventSink when already nil (BAD_ACCESS crash).
  • Loading branch information
mkurz000 committed Nov 27, 2024
1 parent 951162a commit fadb33e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatu
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
BOOL isEnabled = [CLLocationManager locationServicesEnabled];
dispatch_async(dispatch_get_main_queue(), ^(void) {
if (isEnabled) {
self->_eventSink([NSNumber numberWithInt:(ServiceStatus)enabled]);
} else {
self->_eventSink([NSNumber numberWithInt:(ServiceStatus)disabled]);
if (_eventSink != nil) {
if (isEnabled) {
self->_eventSink([NSNumber numberWithInt:(ServiceStatus) enabled]);
} else {
self->_eventSink([NSNumber numberWithInt:(ServiceStatus) disabled]);
}
}
});
});
Expand Down

0 comments on commit fadb33e

Please sign in to comment.