diff --git a/internal/platform/bluetooth_classic.cc b/internal/platform/bluetooth_classic.cc index beade20d..1ab855b0 100644 --- a/internal/platform/bluetooth_classic.cc +++ b/internal/platform/bluetooth_classic.cc @@ -73,6 +73,11 @@ bool BluetoothClassicMedium::StartDiscovery(DiscoveryCallback callback) { [this](api::BluetoothDevice& device) { MutexLock lock(&mutex_); auto item = devices_.extract(&device); + if (!item) { + NEARBY_LOGS(WARNING) + << "Removing unknown device: " << device.GetMacAddress(); + return; + } auto& context = *item.mapped(); NEARBY_LOG(INFO, "Removing device=%p, impl=%p", &context.device, &device);