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

Commit ccb18ded authored by Greg Kaiser's avatar Greg Kaiser
Browse files

SecurityManager: Don't use iterator after erase()

After we erase() 'entry', it is invalidated.  So we cache
entry->second prior to the erase() call, to avoid using
'entry' after erase.

Test: TreeHugger
Change-Id: Icb470cd79bbf1bfda12c2f882c3553fd33755554
parent e0f9b01e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -92,8 +92,9 @@ void SecurityManagerImpl::CreateBond(hci::AddressWithType device) {
void SecurityManagerImpl::CancelBond(hci::AddressWithType device) {
  auto entry = pairing_handler_map_.find(device.GetAddress());
  if (entry != pairing_handler_map_.end()) {
    auto cancel_me = entry->second;
    pairing_handler_map_.erase(entry);
    entry->second->Cancel();
    cancel_me->Cancel();
  }
}