From 39e673811d73ac09a822d9ee0082bba5d8e8cbad Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 15 May 2017 19:26:38 -0700 Subject: ART: Fix iterator invalidation Erasing an item of a map invalidates the iterator. Bug: 38324641 Test: m test-art-host Change-Id: I9f7499eb4a4b49e4fcd6c99d170d9b681adfd9b0 --- runtime/jit/jit_code_cache.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 2bd1d646a1..56efd25a63 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -677,13 +677,13 @@ void JitCodeCache::NotifyMethodRedefined(ArtMethod* method) { } method->SetProfilingInfo(nullptr); ScopedCodeCacheWrite ccw(code_map_.get()); - for (auto code_iter = method_code_map_.begin(); - code_iter != method_code_map_.end(); - ++code_iter) { + for (auto code_iter = method_code_map_.begin(); code_iter != method_code_map_.end();) { if (code_iter->second == method) { FreeCode(code_iter->first); - method_code_map_.erase(code_iter); + code_iter = method_code_map_.erase(code_iter); + continue; } + ++code_iter; } auto code_map = osr_code_map_.find(method); if (code_map != osr_code_map_.end()) { -- cgit v1.2.3-59-g8ed1b