From df7a657f1f9b9f381697708615c956271af9a7b8 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 7 Sep 2025 13:41:10 +0100 Subject: Fix an iterator invalidation when finding the messageflood counter. --- src/modules/m_messageflood.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index d22591515..2422c316f 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -86,7 +86,8 @@ public: CounterMap::iterator Find(User* who) { - CounterMap::iterator ret = counters.end(); + auto found = false; + CounterMap::iterator ret; for (auto it = counters.begin(); it != counters.end(); ) { if (it->second.reset <= ServerInstance->Time()) @@ -94,11 +95,14 @@ public: else { if (it->first == who) + { + found = true; ret = it; + } it++; } } - return ret; + return found ? ret : counters.end(); } }; -- cgit v1.3.1-10-gc9f91