Skip to content

Commit fadb33e

Browse files
committed
MRS-2850 Crash if listen/cancel is executed in quick succession
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).
1 parent 951162a commit fadb33e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

geolocator_apple/ios/Classes/Handlers/LocationServiceStreamHandler.m

+6-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatu
3737
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
3838
BOOL isEnabled = [CLLocationManager locationServicesEnabled];
3939
dispatch_async(dispatch_get_main_queue(), ^(void) {
40-
if (isEnabled) {
41-
self->_eventSink([NSNumber numberWithInt:(ServiceStatus)enabled]);
42-
} else {
43-
self->_eventSink([NSNumber numberWithInt:(ServiceStatus)disabled]);
40+
if (_eventSink != nil) {
41+
if (isEnabled) {
42+
self->_eventSink([NSNumber numberWithInt:(ServiceStatus) enabled]);
43+
} else {
44+
self->_eventSink([NSNumber numberWithInt:(ServiceStatus) disabled]);
45+
}
4446
}
4547
});
4648
});

0 commit comments

Comments
 (0)