summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-22 02:05:51 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-22 02:05:51 +0000
commitbec3231f00ba89deeb2c6d05022ed3071843e915 (patch)
tree56131b58985dc61319662269b406d085c46ea750
parentf14fe0c726e63def4129379abc793117f26ee0d2 (diff)
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
-rw-r--r--src/modules/m_sasl.cpp20
1 files 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))