From 09299595fe4c4e6cbc38d73a47a2586accdc86fa Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Mon, 31 Oct 2016 19:51:52 +0100 Subject: [PATCH] Fix wrong increment of deleted iterator. This fixes the invalid access spotted by valgrind. --- src/observersmanager.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/observersmanager.hpp b/src/observersmanager.hpp index 926c532..18646b8 100644 --- a/src/observersmanager.hpp +++ b/src/observersmanager.hpp @@ -140,8 +140,9 @@ namespace cloonel { template void ObserversManager::RemoveAll() noexcept { if (not m_tree.empty()) { - for (typename TreeType::sibling_iterator it(m_tree.begin()), itEND(m_tree.end()); it != itEND; ++it) { + for (typename TreeType::sibling_iterator it(m_tree.begin()), itEND(m_tree.end()); it != itEND;) { const TicketType ticket = it->ticket; + ++it; this->Remove(ticket); } assert(m_tree.empty());