From 380154d0ba081a0f28a7809594e717bfb0791c8a Mon Sep 17 00:00:00 2001 From: Guogang Li Date: Fri, 11 Apr 2025 14:33:38 -0700 Subject: [PATCH] Properly release objects when stopping BTC advertising. PiperOrigin-RevId: 746593323 --- .../implementation/windows/bluetooth_classic_medium.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/platform/implementation/windows/bluetooth_classic_medium.cc b/internal/platform/implementation/windows/bluetooth_classic_medium.cc index 0af1803f..927b77b3 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_medium.cc +++ b/internal/platform/implementation/windows/bluetooth_classic_medium.cc @@ -937,15 +937,17 @@ bool BluetoothClassicMedium::StopAdvertising() { } catch (std::exception exception) { LOG(ERROR) << __func__ << ": StopAdvertising exception: " << exception.what(); - return false; } catch (const winrt::hresult_error& ex) { LOG(ERROR) << __func__ << ": StopAdvertising exception: " << ex.code() << ": " << winrt::to_string(ex.message()); - return false; } catch (...) { LOG(ERROR) << __func__ << ": Unknown exception."; - return false; } + + rfcomm_provider_ = nullptr; + raw_server_socket_ = nullptr; + server_socket_ = nullptr; + return false; } bool BluetoothClassicMedium::InitializeServiceSdpAttributes(