From eba928e78441e982ccad40a62e357cf68a677a79 Mon Sep 17 00:00:00 2001 From: Aaron Yu Date: Wed, 27 Sep 2023 16:33:23 -0700 Subject: [PATCH] Fix bluetooth adapter null pointer exception PiperOrigin-RevId: 568994552 --- .../platform/implementation/windows/ble_gatt_server.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/platform/implementation/windows/ble_gatt_server.cc b/internal/platform/implementation/windows/ble_gatt_server.cc index 9dfe45db..6fe40e07 100644 --- a/internal/platform/implementation/windows/ble_gatt_server.cc +++ b/internal/platform/implementation/windows/ble_gatt_server.cc @@ -221,7 +221,12 @@ bool BleGattServer::InitializeGattServer() { NEARBY_LOGS(VERBOSE) << __func__ << ": Create GATT service service_uuid=" << std::string(service_uuid_); - if (adapter_ == nullptr || !adapter_->IsEnabled()) { + if (adapter_ == nullptr) { + NEARBY_LOGS(ERROR) << __func__ << ": Bluetooth adapter is absent."; + return false; + } + + if (!adapter_->IsEnabled()) { NEARBY_LOGS(ERROR) << __func__ << ": Bluetooth adapter is disabled."; return false; }