From 2becac52d587a4fe339383a9982fa5c5cc99631c Mon Sep 17 00:00:00 2001 From: Andrei Molotkov Date: Thu, 17 Jun 2021 19:09:10 +0300 Subject: [PATCH] [IE CLDNN] Fix iterator invalidation --- inference-engine/thirdparty/clDNN/src/program.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inference-engine/thirdparty/clDNN/src/program.cpp b/inference-engine/thirdparty/clDNN/src/program.cpp index 5b9ef6583b9879..1e954cb4b388b8 100644 --- a/inference-engine/thirdparty/clDNN/src/program.cpp +++ b/inference-engine/thirdparty/clDNN/src/program.cpp @@ -831,7 +831,9 @@ void program_impl::swap_names(program_node& node1, program_node& node2) { } void program_impl::replace_all_usages(program_node& old_node, program_node& new_node) { - for (auto& user : old_node.users) { + auto itr = old_node.users.begin(); + while (itr != old_node.users.end()) { + auto user = *(itr++); user->replace_dependency(old_node, new_node); } }