shill: Fix crash on VPN connection failure
If ThirdPartyVpnDriver::OnDefaultServiceChanged() is invoked before
the VPN app is able to handle reconnections, it will call Cleanup()
which calls Manager::DeregisterDefaultServiceCallback() and erases
the current element from the std::map. This invalidates the reference
to the element, causing the loop to segfault.
So, switch back to an iterator, and advance the iterator before invoking
the callback so that it is safe for the callback to erase the current
element.
BUG=chromium:661597
TEST=`FEATURES=test emerge-link shill`
TEST=manually reproduce the problem described in the bug, and verify
that shill no longer crashes
Change-Id: I47e1ffdaa8685467e288f6b29e8396d7dced4caa
Reviewed-on: https://chromium-review.googlesource.com/414612
Commit-Ready: Kevin Cernekee <cernekee@chromium.org>
Tested-by: Kevin Cernekee <cernekee@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Kirtika Ruchandani <kirtika@chromium.org>
(cherry picked from commit c645a4451726b1c37e02c8fcaed71a18bf63ef52)
1 file changed