From 6def9bd67ce536ee4ae95fa4e8342a61da6d338f Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Fri, 10 Mar 2017 11:19:48 -0800 Subject: [PATCH] adb: properly erase destroyed jdwp_trackers. std::remove_if moves to-be-removed elements to the end of the vector and returns an iterator that must be .erased. Bug: http://b/35772578 Test: mma Change-Id: Idfe8520e176204ac5ce000c30704873a3ffe6c9c --- adb/jdwp_service.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adb/jdwp_service.cpp b/adb/jdwp_service.cpp index 3135aa42a..9589d8885 100644 --- a/adb/jdwp_service.cpp +++ b/adb/jdwp_service.cpp @@ -571,7 +571,8 @@ static void jdwp_tracker_close(asocket* s) { remove_socket(s); auto pred = [s](const auto& tracker) { return tracker.get() == s; }; - std::remove_if(_jdwp_trackers.begin(), _jdwp_trackers.end(), pred); + _jdwp_trackers.erase(std::remove_if(_jdwp_trackers.begin(), _jdwp_trackers.end(), pred), + _jdwp_trackers.end()); } static void jdwp_tracker_ready(asocket* s) {