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

Commit 4b55f4d3 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

AVRCP: Advance iterator before deleting it

When we invoke instance_->avrc_->Close(), it will invoke the callback in
AcceptorControlCb by the state machine from AVCT, and the iterator will
be deleted. Now we advanece the iterator first.

Bug: 169747177
Test: Connect to a speaker with AVRCP, and turn off Bluetooth
Tag: #stability
Change-Id: If4ed403d355242da48b7ee49dd74784f43de1b1d
parent 5e1cf5ce
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -85,9 +85,12 @@ bool ConnectionHandler::CleanUp() {
  CHECK(instance_ != nullptr);

  // TODO (apanicke): Cleanup the SDP Entries here
  for (const auto& entry : instance_->device_map_) {
    entry.second->DeviceDisconnected();
    instance_->avrc_->Close(entry.first);
  for (auto entry = instance_->device_map_.begin();
       entry != instance_->device_map_.end();) {
    auto curr = entry;
    entry++;
    curr->second->DeviceDisconnected();
    instance_->avrc_->Close(curr->first);
  }
  instance_->device_map_.clear();
  instance_->feature_map_.clear();