From 5692781e9a9360a6efe73659d8c2deb15d7bc3ba Mon Sep 17 00:00:00 2001 From: Michael Kurz Date: Wed, 27 Nov 2024 13:11:35 +0100 Subject: [PATCH 1/3] [geolocator_apple] 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). --- .../Classes/Handlers/LocationServiceStreamHandler.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/geolocator_apple/ios/Classes/Handlers/LocationServiceStreamHandler.m b/geolocator_apple/ios/Classes/Handlers/LocationServiceStreamHandler.m index ac6e8ff4..208ef6ca 100644 --- a/geolocator_apple/ios/Classes/Handlers/LocationServiceStreamHandler.m +++ b/geolocator_apple/ios/Classes/Handlers/LocationServiceStreamHandler.m @@ -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]); + } } }); }); From 41916122442be857bf763564a784389611e6a3f8 Mon Sep 17 00:00:00 2001 From: Michael Kurz Date: Wed, 27 Nov 2024 15:25:56 +0100 Subject: [PATCH 2/3] [geolocator_apple] Update changelog and version --- geolocator_apple/CHANGELOG.md | 4 ++++ geolocator_apple/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/geolocator_apple/CHANGELOG.md b/geolocator_apple/CHANGELOG.md index a62b2666..6fb00777 100644 --- a/geolocator_apple/CHANGELOG.md +++ b/geolocator_apple/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.3.8+2 + +* Crash if listen/cancel is executed in quick succession + ## 2.3.8+1 * HOT FIX: Adds back implementation of the `stopListening` method in the `GeolocationHandler.m` file. diff --git a/geolocator_apple/pubspec.yaml b/geolocator_apple/pubspec.yaml index 270b13a3..75311daf 100644 --- a/geolocator_apple/pubspec.yaml +++ b/geolocator_apple/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator_apple description: Geolocation Apple plugin for Flutter. This plugin provides the Apple implementation for the geolocator. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_apple issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 2.3.8+1 +version: 2.3.8+2 environment: sdk: ">=2.15.0 <4.0.0" From f2ede34ef8abefea5d4b0016621e5a65405d1e22 Mon Sep 17 00:00:00 2001 From: Michael Kurz Date: Wed, 27 Nov 2024 15:30:44 +0100 Subject: [PATCH 3/3] Update changelog and version --- geolocator/CHANGELOG.md | 4 ++++ geolocator/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/geolocator/CHANGELOG.md b/geolocator/CHANGELOG.md index dfe7dcd9..6cac177d 100644 --- a/geolocator/CHANGELOG.md +++ b/geolocator/CHANGELOG.md @@ -1,3 +1,7 @@ +## 13.0.3 + +- Updates dependency on geolocator_apple. + ## 13.0.2 - Updates dependency on geolocator_apple to version 2.3.8. diff --git a/geolocator/pubspec.yaml b/geolocator/pubspec.yaml index 12d08022..23ba63b1 100644 --- a/geolocator/pubspec.yaml +++ b/geolocator/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator description: Geolocation plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API for generic location (GPS etc.) functions. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 13.0.2 +version: 13.0.3 environment: sdk: ">=2.15.0 <4.0.0"