From d5ed44d65c041f945484e5c2ff682b121aa64c90 Mon Sep 17 00:00:00 2001 From: peavey Date: Mon, 13 Nov 2006 15:25:28 +0000 Subject: fix for bug #173, unsafe delete while iterating git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5737 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/users.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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 */ -- cgit v1.2.3