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_clearusers.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'modules/commands/cs_clearusers.cpp') diff --git a/modules/commands/cs_clearusers.cpp b/modules/commands/cs_clearusers.cpp index 9a50f70c9..d6eed6e4d 100644 --- a/modules/commands/cs_clearusers.cpp +++ b/modules/commands/cs_clearusers.cpp @@ -47,13 +47,17 @@ class CommandCSClearUsers : public Command Anope::string buf = "CLEARUSERS command from " + source.GetNick() + " (" + source.nc->display + ")"; - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) + std::vector users; + for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) { - UserContainer *uc = *it++; - - c->Kick(NULL, uc->user, "%s", buf.c_str()); + User *user = (*it)->user; + if (!user->HasMode(UMODE_OPER) && user->server != Me) + users.push_back(user); } + for (unsigned i = 0; i < users.size(); ++i) + c->Kick(NULL, users[i], "%s", buf.c_str()); + bool override = !source.AccessFor(c->ci).HasPriv("FOUNDER"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci); -- cgit