From 313efed9c9dc95b610a4a933ba7faf487de1ea0f Mon Sep 17 00:00:00 2001 From: Francis Tsui Date: Thu, 7 May 2026 22:17:02 -0700 Subject: [PATCH] Fix unprotected multi-threaded access to list. PiperOrigin-RevId: 912324436 --- internal/platform/implementation/windows/wifi_hotspot.h | 2 +- .../platform/implementation/windows/wifi_hotspot_medium.cc | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/platform/implementation/windows/wifi_hotspot.h b/internal/platform/implementation/windows/wifi_hotspot.h index c6b4c34a..b68926ec 100644 --- a/internal/platform/implementation/windows/wifi_hotspot.h +++ b/internal/platform/implementation/windows/wifi_hotspot.h @@ -111,7 +111,7 @@ class WifiHotspotMedium : public api::WifiHotspotMedium { WiFiDirectConnectionListener listener_{nullptr}; // The list of WiFiDirectDevice is used to keep hotspot connection alive. - std::list wifi_direct_devices_; + std::list wifi_direct_devices_ ABSL_GUARDED_BY(mutex_); fire_and_forget OnStatusChanged( WiFiDirectAdvertisementPublisher sender, diff --git a/internal/platform/implementation/windows/wifi_hotspot_medium.cc b/internal/platform/implementation/windows/wifi_hotspot_medium.cc index 288efe14..e6ca86bd 100644 --- a/internal/platform/implementation/windows/wifi_hotspot_medium.cc +++ b/internal/platform/implementation/windows/wifi_hotspot_medium.cc @@ -349,7 +349,10 @@ fire_and_forget WifiHotspotMedium::OnConnectionRequested( auto wifi_direct_device = WiFiDirectDevice::FromIdAsync( connection_request.DeviceInformation().Id()) .get(); - wifi_direct_devices_.push_back(wifi_direct_device); + { + absl::MutexLock lock(mutex_); + wifi_direct_devices_.push_back(wifi_direct_device); + } LOG(INFO) << "Registered the device " << winrt::to_string(device_name) << " in WLAN-AutoConfig"; } catch (...) {