From 516e95e6f6c474018cb57f30934cb68296243730 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 21 Apr 2008 16:24:44 +0000 Subject: Patch to fix timedbans crash reported earlier today, thanks for the headsup wonderwal git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9563 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_timedbans.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 4be32ffc2..6247f32d6 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -158,17 +158,28 @@ class ModuleTimedBans : public Module if (cr) { const char *setban[3]; + std::string mask = i->mask; + setban[0] = i->channel.c_str(); setban[1] = "-b"; - setban[2] = i->mask.c_str(); - - ServerInstance->PI->SendModeStr(i->channel, std::string("-b ") + setban[2]); - ServerInstance->SendMode(setban,3, ServerInstance->FakeClient); + setban[2] = mask.c_str(); CUList empty; cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :*** Timed ban on %s expired.", cr->name, i->mask.c_str()); if (ServerInstance->Config->AllowHalfop) cr->WriteAllExcept(ServerInstance->FakeClient, true, '%', empty, "NOTICE %s :*** Timed ban on %s expired.", cr->name, i->mask.c_str()); + + ServerInstance->PI->SendModeStr(i->channel, std::string("-b ") + setban[2]); + ServerInstance->SendMode(setban,3, ServerInstance->FakeClient); + + bool was_removed = true; + for (BanList::iterator j = cr->bans.begin(); j != cr->bans.end(); j++) + if (!strcasecmp(j->data, mask.c_str())) + was_removed = false; + + /* Fix for crash if user cycles before the ban expires */ + if (!was_removed) + TimedBanList.erase(i); } else { -- cgit v1.2.3