diff options
author | 2017-05-15 19:26:38 -0700 | |
---|---|---|
committer | 2017-05-15 19:26:38 -0700 | |
commit | 39e673811d73ac09a822d9ee0082bba5d8e8cbad (patch) | |
tree | 2c298cbabbd476b103da0269e5cbb68de18faf61 | |
parent | ed00ddb614d68559931d831cb74d3ba8f01599c9 (diff) |
ART: Fix iterator invalidation
Erasing an item of a map invalidates the iterator.
Bug: 38324641
Test: m test-art-host
Change-Id: I9f7499eb4a4b49e4fcd6c99d170d9b681adfd9b0
-rw-r--r-- | runtime/jit/jit_code_cache.cc | 8 |
1 files 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()) { |