From 7b36b63abf095989b88f2b62f21babb499ac0606 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 15 Aug 2019 16:01:49 +0900 Subject: [PATCH] Fix invalid access While calling Exit(), the iterator is removed. Before calling Exit(), the iterator has to be the next iterator. Change-Id: I36f61cafbf81442dc12a2dbe32573f24e9da7458 Signed-off-by: Hwankyu Jhun --- component_based/base/component_manager_internal.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/component_based/base/component_manager_internal.cc b/component_based/base/component_manager_internal.cc index f2bee5b..8bb18c1 100644 --- a/component_based/base/component_manager_internal.cc +++ b/component_based/base/component_manager_internal.cc @@ -147,8 +147,11 @@ void ComponentManager::ExitAll() { if (inst_map_.empty()) return; - for (auto i = inst_map_.begin(); i != inst_map_.end(); i++) { + auto iter = inst_map_.begin(); + while (iter != inst_map_.end()) { + auto i = iter; LOGD("Exit instance(%s)", i->first.c_str()); + iter++; Exit(i->first); } } -- 2.34.1