Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 71b58400 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

GATT connection_manager: Fix logic to remove white list device

Device in bgconn_dev will be removed when no app is using it. Fix the
logic to prevent from use after free.

Bug: 123297334
Test: Manual
Change-Id: I35a0191ba48fabbcf28525388dfa63b93b20c96d
parent ad862c5b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -167,11 +167,11 @@ void on_app_deregistered(uint8_t app_id) {
void on_connection_complete(const RawAddress& address) {
  VLOG(2) << __func__;
  auto it = bgconn_dev.find(address);
  if (it == bgconn_dev.end()) return;

  while (!it->second.doing_direct_conn.empty()) {
  while (it != bgconn_dev.end() && !it->second.doing_direct_conn.empty()) {
    uint8_t app_id = it->second.doing_direct_conn.begin()->first;
    direct_connect_remove(app_id, address);
    it = bgconn_dev.find(address);
  }
}