Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 1.7.5

### Fixed

- **A second `startDiscovery()` crashed release builds on macOS.** Starting a
new inquiry replaced the old inquiry's delegate before releasing the old
`IOBluetoothDeviceInquiry`. The inquiry does not retain its delegate, so its
`dealloc` touched freed memory and the app died with `EXC_BAD_ACCESS` in
`-[IOBluetoothDeviceInquiry dealloc]`. Debug builds usually survived because
the delegate was freed later. The previous inquiry is now detached from its
delegate, stopped and released before the new one is created.

## 1.7.4

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ public class FlutterClassicBluetoothPlugin: NSObject, FlutterPlugin {
result(nil)
return
}
// IOBluetoothDeviceInquiry does not retain its delegate, and its dealloc
// still touches it. Retire the previous inquiry while its delegate is
// alive, otherwise replacing `inquiryDelegate` first leaves the old
// inquiry pointing at freed memory and releasing it crashes.
if let previous = inquiry {
previous.delegate = nil
previous.stop()
inquiry = nil
}
inquiryDelegate = nil

discovering = true
discoveryStateHandler?.eventSink?(true)

Expand Down