From 18e9e12261fa97aa47daf7d0fb729afd366aa5d6 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 18 May 2024 16:35:14 +0100 Subject: [PATCH] Fix an iterator invalidation issue in cs_set and ns_set. --- modules/chanserv/cs_set.cpp | 2 +- modules/nickserv/ns_set.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/chanserv/cs_set.cpp b/modules/chanserv/cs_set.cpp index c7952baba..932d1f43c 100644 --- a/modules/chanserv/cs_set.cpp +++ b/modules/chanserv/cs_set.cpp @@ -1146,7 +1146,7 @@ public: if (c->ci && keep_modes.HasExt(c->ci)) { Channel::ModeList ml = c->ci->last_modes; - for (const auto &[last_mode, last_value] : c->ci->last_modes) + for (const auto &[last_mode, last_value] : ml) c->SetMode(c->ci->WhoSends(), last_mode, last_value); } } diff --git a/modules/nickserv/ns_set.cpp b/modules/nickserv/ns_set.cpp index 88d8d97dd..6467ed311 100644 --- a/modules/nickserv/ns_set.cpp +++ b/modules/nickserv/ns_set.cpp @@ -1354,7 +1354,8 @@ public: { if (keep_modes.HasExt(u->Account())) { - for (const auto &[last_mode, last_value] : u->Account()->last_modes) + User::ModeList modes = u->Account()->last_modes; + for (const auto &[last_mode, last_value] : modes) { UserMode *um = ModeManager::FindUserModeByName(last_mode); /* if the null user can set the mode, then it's probably safe */