summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2006-11-13 15:25:28 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2006-11-13 15:25:28 +0000
commitd5ed44d65c041f945484e5c2ff682b121aa64c90 (patch)
treec3753c9f36f54d6ae5ad29bc13769b45dab94a50 /src/users.cpp
parentc33de81eecbbce2850db626272f1008a3a332dfc (diff)
fix for bug #173, unsafe delete while iterating
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5737 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 184eef8ef..d2e632b10 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -888,7 +888,8 @@ namespace irc
int groupcount = ServerInstance->whowas.size();
/* iterate whowas_fifo oldest first */
- for (whowas_users_fifo::iterator iter = ServerInstance->whowas_fifo.begin(); iter != ServerInstance->whowas_fifo.end(); iter++)
+ whowas_users_fifo::iterator iter, safeiter;
+ for (iter = ServerInstance->whowas_fifo.begin(); iter != ServerInstance->whowas_fifo.end(); iter++)
{
/** prune all groups that has expired due to new maxkeep time and
* also any group number higher than new maxgroups. The oldest are
@@ -907,7 +908,10 @@ namespace irc
}
}
ServerInstance->whowas.erase(iter->second);
- ServerInstance->whowas_fifo.erase(iter->first);
+ /* use a safe iter copy for erase and set the orig iter old valid ref by decrementing it */
+ safeiter = iter;
+ iter--;
+ ServerInstance->whowas_fifo.erase(safeiter);
}
else {
/* also trim individual groupsizes in case groupsize should have been lowered */