summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-17 01:14:18 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-17 01:14:18 +0000
commite2322b3feb0b70a5c5d74fff4a9ab2bd7c85bcac (patch)
treeebd521dda4573c3f9969108e365a9db1973bbc8d /src/modules
parentc2b1ee00bc62aca5df1ae91bfbca5e0580474b24 (diff)
Use safe iter for deleting while iterating
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6024 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_svshold.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index 945125c75..8c81427e9 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -242,33 +242,22 @@ class ModuleSVSHold : public Module
void ExpireBans()
{
- bool go_again = true;
-
- while (go_again)
+ SVSHoldlist::iterator iter,safeiter;
+ for (iter = SVSHolds.begin(); iter != SVSHolds.end(); iter++)
{
- go_again = false;
-
- for (SVSHoldlist::iterator iter = SVSHolds.begin(); iter != SVSHolds.end(); iter++)
+ /* 0 == permanent, don't mess with them! -- w00t */
+ if ((*iter)->length != 0)
{
- /* 0 == permanent, don't mess with them! -- w00t */
- if ((*iter)->length != 0)
+ if ((*iter)->set_on + (*iter)->length <= ServerInstance->Time())
{
- if ((*iter)->set_on + (*iter)->length <= ServerInstance->Time())
- {
- ServerInstance->Log(DEBUG, "m_svshold.so: hold on %s expired, removing...", (*iter)->nickname.c_str());
- ServerInstance->WriteOpers("*** %li second SVSHOLD on %s (%s) set %u seconds ago expired", (*iter)->length, (*iter)->nickname.c_str(), (*iter)->reason.c_str(), ServerInstance->Time() - (*iter)->set_on);
- HoldMap.erase(assign((*iter)->nickname));
-
- delete *iter;
-
- SVSHolds.erase(iter);
-
- go_again = true;
- }
+ ServerInstance->Log(DEBUG, "m_svshold.so: hold on %s expired, removing...", (*iter)->nickname.c_str());
+ ServerInstance->WriteOpers("*** %li second SVSHOLD on %s (%s) set %u seconds ago expired", (*iter)->length, (*iter)->nickname.c_str(), (*iter)->reason.c_str(), ServerInstance->Time() - (*iter)->set_on);
+ HoldMap.erase(assign((*iter)->nickname));
+ delete *iter;
+ safeiter = iter;
+ --iter;
+ SVSHolds.erase(safeiter);
}
-
- if (go_again == true)
- break;
}
}
}