]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix incorrect iterator use leading to prematurely exiting loops when quitting users...
authorAttila Molnar <attilamolnar@hush.com>
Sun, 17 May 2015 16:00:42 +0000 (18:00 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Sun, 17 May 2015 16:00:42 +0000 (18:00 +0200)
src/inspircd.cpp
src/modules/m_close.cpp
src/modules/m_jumpserver.cpp
src/modules/m_nationalchars.cpp

index cb2b5db9d7a27aa88a05553cdd6b6602887a418c..5dfcca6d995d927d0710f38d791ce637f5406907 100644 (file)
@@ -110,8 +110,8 @@ void InspIRCd::Cleanup()
 
        /* Close all client sockets, or the new process inherits them */
        const UserManager::LocalList& list = Users.GetLocalUsers();
-       for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
-               Users->QuitUser(*i, "Server shutdown");
+       while (!list.empty())
+               Users->QuitUser(list.front(), "Server shutdown");
 
        GlobalCulls.Apply();
        Modules->UnloadAll();
index f3c751f177558f9df8af90a690657206c7745629..3f0eedaafcfb9e961ddf779422b37ee75fc306e5 100644 (file)
@@ -36,9 +36,11 @@ class CommandClose : public Command
                std::map<std::string,int> closed;
 
                const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
-               for (UserManager::LocalList::const_iterator u = list.begin(); u != list.end(); ++u)
+               for (UserManager::LocalList::const_iterator u = list.begin(); u != list.end(); )
                {
+                       // Quitting the user removes it from the list
                        LocalUser* user = *u;
+                       ++u;
                        if (user->registered != REG_ALL)
                        {
                                ServerInstance->Users->QuitUser(user, "Closing all unknown connections per request");
index 599144448833c1aea22837fbfd4543b915151672..e9c07f45fda18816a003a1017d8f3d150a7ff184 100644 (file)
@@ -109,9 +109,11 @@ class CommandJumpserver : public Command
                        {
                                /* Redirect everyone but the oper sending the command */
                                const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
-                               for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
+                               for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); )
                                {
+                                       // Quitting the user removes it from the list
                                        LocalUser* t = *i;
+                                       ++i;
                                        if (!t->IsOper())
                                        {
                                                t->WriteNumeric(RPL_REDIR, "%s %d :Please use this Server/Port instead", parameters[0].c_str(), GetPort(t));
index f77899ad4f8105edc521e732b148720d8fbb5f97..8e74ee3e6d697b0dfb258e956983daa43f6246af 100644 (file)
@@ -292,10 +292,12 @@ class ModuleNationalChars : public Module
                        return;
 
                const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
-               for (UserManager::LocalList::const_iterator iter = list.begin(); iter != list.end(); ++iter)
+               for (UserManager::LocalList::const_iterator iter = list.begin(); iter != list.end(); )
                {
                        /* Fix by Brain: Dont quit UID users */
+                       // Quitting the user removes it from the list
                        User* n = *iter;
+                       ++iter;
                        if (!isdigit(n->nick[0]) && !ServerInstance->IsNick(n->nick))
                                ServerInstance->Users->QuitUser(n, message);
                }