]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_channames.cpp
m_mysql Fix crash on rehash when the database tags have been changed in the config
[user/henk/code/inspircd.git] / src / modules / m_channames.cpp
index 559ec5314e6d324101e8b823fc3da36259a68775..b5f5853e739bfc0acfbf7af0bf9c54d9cf6af254 100644 (file)
@@ -63,7 +63,7 @@ class ModuleChannelNames : public Module
        {
                ServerInstance->IsChannel = &myhandler;
                Implementation eventlist[] = { I_OnRehash, I_OnUserKick };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
                OnRehash(NULL);
        }
 
@@ -89,9 +89,17 @@ class ModuleChannelNames : public Module
                                ServerInstance->SendGlobalMode(modes, ServerInstance->FakeClient);
                        }
                        const UserMembList* users = c->GetUsers();
-                       for(UserMembCIter j = users->begin(); j != users->end(); ++j)
+                       for(UserMembCIter j = users->begin(); j != users->end(); )
+                       {
                                if (IS_LOCAL(j->first))
-                                       c->KickUser(ServerInstance->FakeClient, j->first, "Channel name no longer valid");
+                               {
+                                       // KickUser invalidates the iterator
+                                       UserMembCIter it = j++;
+                                       c->KickUser(ServerInstance->FakeClient, it->first, "Channel name no longer valid");
+                               }
+                               else
+                                       ++j;
+                       }
                }
                badchan = false;
        }