From 7f3b56c28bb72b4e3fa42e470fa45d3a7540eecb Mon Sep 17 00:00:00 2001 From: maxime1907 <19607336+maxime1907@users.noreply.github.com> Date: Tue, 4 Feb 2025 20:54:14 +0100 Subject: [PATCH] fix: ispaused invalid iterator --- core/sourcehook/sourcehook_impl.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/sourcehook/sourcehook_impl.h b/core/sourcehook/sourcehook_impl.h index 96cba35b..c9c9608c 100644 --- a/core/sourcehook/sourcehook_impl.h +++ b/core/sourcehook/sourcehook_impl.h @@ -256,9 +256,20 @@ namespace SourceHook ICleanupTask *m_CleanupTask; + bool isValidIterator(List::iterator &myIter, List &myList) { + for (auto iter = myList.begin(); iter != myList.end(); ++iter) { + if (iter == myIter) { + return true; + } + } + return false; + } + void SkipPaused(List::iterator &iter, List &list) { - while (iter != list.end() && iter->IsPaused()) + if (!iter || !isValidIterator(iter, list)) + iter = list.end(); + while (iter != list.end() && iter && iter->IsPaused()) ++iter; } public: