From 8b78b6bb104e8c1088d066f153967678b50a15a8 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 7 Nov 2012 15:41:49 -0500 Subject: Fix crash on suspend etc if kicking a user causes the service bot to part when the service bot is next in the userlist (as we have an iterator to it) --- modules/commands/cs_suspend.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'modules/commands/cs_suspend.cpp') diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index 9cb829ad1..bce549e79 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -102,15 +102,18 @@ class CommandCSSuspend : public Command if (ci->c) { - for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ) - { - UserContainer *uc = *it++; - - if (uc->user->HasMode(UMODE_OPER)) - continue; + std::vector users; - ci->c->Kick(NULL, uc->user, "%s", !reason.empty() ? reason.c_str() : translate(uc->user, _("This channel has been suspended."))); + for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + { + UserContainer *uc = *it; + User *user = uc->user; + if (!user->HasMode(UMODE_OPER) && user->server != Me) + users.push_back(user); } + + for (unsigned i = 0; i < users.size(); ++i) + ci->c->Kick(NULL, users[i], "%s", !reason.empty() ? reason.c_str() : translate(users[i], _("This channel has been suspended."))); } if (expiry_secs > 0) -- cgit