diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-07-01 20:47:07 +0200 |
---|---|---|
committer | Robin Burchell <robin+git@viroteck.net> | 2012-07-01 21:04:21 +0200 |
commit | 98a932f819e2f55dc3fafb160d55a1aa57a3d5cf (patch) | |
tree | 0750006259a420c4157d1827a7470d7a74ae4ae5 | |
parent | 183b182b3d6c0c32f4d10e131a55adbf54b8be01 (diff) |
m_dccallow Fix unsafe iteration
-rw-r--r-- | src/modules/m_dccallow.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 8c2a5f73e..0c1c5a185 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -274,7 +274,9 @@ class ModuleDCCAllow : public Module // remove their DCCALLOW list if they have one if (udl) { - RemoveFromUserlist(user); + userlist::iterator it = std::find(ul.begin(), ul.end(), user); + if (it != ul.end()) + ul.erase(it); } // remove them from any DCCALLOW lists @@ -381,7 +383,7 @@ class ModuleDCCAllow : public Module void Expire() { - for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter) + for (userlist::iterator iter = ul.begin(); iter != ul.end();) { User* u = (User*)(*iter); dl = ext->get(u); @@ -403,10 +405,11 @@ class ModuleDCCAllow : public Module } } } + ++iter; } else { - RemoveFromUserlist(u); + iter = ul.erase(iter); } } } @@ -414,7 +417,7 @@ class ModuleDCCAllow : public Module void RemoveNick(User* user) { /* Iterate through all DCCALLOW lists and remove user */ - for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter) + for (userlist::iterator iter = ul.begin(); iter != ul.end();) { User *u = (User*)(*iter); dl = ext->get(u); @@ -434,10 +437,11 @@ class ModuleDCCAllow : public Module } } } + ++iter; } else { - RemoveFromUserlist(u); + iter = ul.erase(iter); } } } |