From 377e09abd9346ca81d267986435c28dc80e664bf Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Sun, 9 Sep 2018 13:12:44 +0300 Subject: [PATCH] src: Check that `Once` hooks to remove exist Fixes #2370. --- src/hook_manager.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hook_manager.cc b/src/hook_manager.cc index 3b63ee56..46d38fb0 100644 --- a/src/hook_manager.cc +++ b/src/hook_manager.cc @@ -127,8 +127,11 @@ void HookManager::run_hook(StringView hook_name, StringView param, Context& cont if (to_run.hook->flags & HookFlags::Once) { auto it = find(hook_list->value, to_run.hook); - m_hooks_trash.push_back(std::move(*it)); - hook_list->value.erase(it); + if (it != hook_list->value.end()) + { + m_hooks_trash.push_back(std::move(*it)); + hook_list->value.erase(it); + } } } catch (runtime_error& err)