diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-12-08 16:14:19 +0100 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2012-12-08 16:24:09 +0100 |
commit | e3efb6a0f69203929d9042f9a7b14ba81cf71ddb (patch) | |
tree | ec9a7b07ed22d182e248961348e75edc40a3358b /src/mode.cpp | |
parent | 0a0aa94537dd1be4a4acc2e992dee8d455328240 (diff) |
Fix unsafe iteration in DelMode() when unloading m_permchannels
Diffstat (limited to 'src/mode.cpp')
-rw-r--r-- | src/mode.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/mode.cpp b/src/mode.cpp index 0957184b7..35f64ce00 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -675,15 +675,20 @@ bool ModeParser::DelMode(ModeHandler* mh) switch (mh->GetModeType()) { case MODETYPE_USER: - for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++) + for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); ) { - mh->RemoveMode(i->second); + User* user = i->second; + ++i; + mh->RemoveMode(user); } break; case MODETYPE_CHANNEL: - for (chan_hash::iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); i++) + for (chan_hash::iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ) { - mh->RemoveMode(i->second); + // The channel may not be in the hash after RemoveMode(), see m_permchannels + Channel* chan = i->second; + ++i; + mh->RemoveMode(chan); } break; } |