From bec3231f00ba89deeb2c6d05022ed3071843e915 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 22 Mar 2008 02:05:51 +0000 Subject: Fix memory leak if user quits in the middle of sasl AUTHENTICATE steps git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9173 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_sasl.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index c9586bf97..ad24fa0d8 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -195,8 +195,8 @@ class ModuleSASL : public Module ModuleSASL(InspIRCd* Me) : Module(Me) { - Implementation eventlist[] = { I_OnEvent, I_OnUserRegister, I_OnPostConnect }; - ServerInstance->Modules->Attach(eventlist, this, 3); + Implementation eventlist[] = { I_OnEvent, I_OnUserRegister, I_OnPostConnect, I_OnUserDisconnect, I_OnCleanup }; + ServerInstance->Modules->Attach(eventlist, this, 5); sasl = new CommandAuthenticate(ServerInstance, this); ServerInstance->AddCommand(sasl); @@ -218,6 +218,22 @@ class ModuleSASL : public Module return 0; } + virtual void OnCleanup(int target_type, void *item) + { + if (target_type == TYPE_USER) + OnUserDisconnect((User*)item); + } + + virtual void OnUserDisconnect(User *user) + { + SaslAuthenticator *sasl_; + if (user->GetExt("sasl_authenticator", sasl_)) + { + delete sasl_; + user->Shrink("sasl_authenticator"); + } + } + virtual void OnPostConnect(User* user) { if (!IS_LOCAL(user)) -- cgit v1.2.3