summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-06-18 22:49:47 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-06-18 22:49:47 +0000
commit61838d28cf0d1323edb2ec4acccfb36a5d96fe00 (patch)
treeb5f00dc8a344c0907868de48a29310853afdba69
parent06c4fa4299f6a1b3dd13356dc57d0dcf32353b71 (diff)
This should be safe. Someone test module loading and unloading during use and make sure stuff doesnt fall over.
Also test some misconfigured modules, e.g. try and load m_services with m_services_account. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7388 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/inspircd.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 66e8a530b..3e063c26b 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -953,6 +953,7 @@ bool InspIRCd::LoadModule(const char* filename)
return false;
}
}
+ Module* m = NULL;
try
{
ircd_module* a = new ircd_module(this, modfile);
@@ -966,7 +967,7 @@ bool InspIRCd::LoadModule(const char* filename)
}
if ((long)factory[this->ModCount+1]->factory != -1)
{
- Module* m = factory[this->ModCount+1]->factory->CreateModule(this);
+ m = factory[this->ModCount+1]->factory->CreateModule(this);
Version v = m->GetVersion();
@@ -1001,6 +1002,7 @@ bool InspIRCd::LoadModule(const char* filename)
{
this->Log(DEFAULT,"Unable to load %s",modfile);
snprintf(MODERR,MAXBUF,"Factory function failed: Probably missing init_module() entrypoint.");
+ delete a;
return false;
}
}
@@ -1008,6 +1010,9 @@ bool InspIRCd::LoadModule(const char* filename)
{
this->Log(DEFAULT,"Unable to load %s: %s",modfile,modexcept.GetReason());
snprintf(MODERR,MAXBUF,"Factory function of %s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
+ if (m)
+ delete m;
+ delete a;
return false;
}
}