diff options
| author | 2025-09-07 13:41:10 +0100 | |
|---|---|---|
| committer | 2025-09-07 13:41:10 +0100 | |
| commit | df7a657f1f9b9f381697708615c956271af9a7b8 (patch) | |
| tree | 6e066d944647744231007b4cdd86b5908d6e9fd9 /src/modules/m_messageflood.cpp | |
| parent | Lower the weight of tag messages from 0.2 to 0.1. (diff) | |
Fix an iterator invalidation when finding the messageflood counter.
Diffstat (limited to 'src/modules/m_messageflood.cpp')
| -rw-r--r-- | src/modules/m_messageflood.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
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(); } }; |
