summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-11-04 22:58:40 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-11-04 22:58:40 +0000
commitcd44daa962c7b22f5564a771b78fcc63458b5eb8 (patch)
tree0b6571b74b7ca68472b5d0bdd524a449b07e63a2 /src
parent53afaa7cadcdf222dcf761441727305f79b4c557 (diff)
On failure to load a module, DetachAll on the module pointer, also, try to free module handle
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8537 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index ef494a7c6..d4e56f3fb 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -404,13 +404,15 @@ bool ModuleManager::Load(const char* filename)
newhandle = new ircd_module(Instance, modfile, "init_module");
newmod = newhandle->CallInit();
- if(newmod)
+ if (newmod)
{
Version v = newmod->GetVersion();
if (v.API != API_VERSION)
{
+ DetachAll(newmod);
delete newmod;
+ delete newhandle;
LastModuleError = "Unable to load " + filename_str + ": Incorrect module API version: " + ConvToStr(v.API) + " (our version: " + ConvToStr(API_VERSION) + ")";
Instance->Log(DEFAULT, LastModuleError);
return false;
@@ -424,25 +426,42 @@ bool ModuleManager::Load(const char* filename)
}
else
{
+ delete newhandle;
LastModuleError = "Unable to load " + filename_str + ": Probably missing init_module() entrypoint, but dlsym() didn't notice a problem";
Instance->Log(DEFAULT, LastModuleError);
return false;
}
}
+ /** XXX: Is there anything we can do about this mess? -- Brain */
catch (LoadModuleException& modexcept)
{
+ DetachAll(newmod);
+ if (newmod)
+ delete newmod;
+ if (newhandle)
+ delete newhandle;
LastModuleError = "Unable to load " + filename_str + ": Error when loading: " + modexcept.GetReason();
Instance->Log(DEFAULT, LastModuleError);
return false;
}
catch (FindSymbolException& modexcept)
{
+ DetachAll(newmod);
+ if (newmod)
+ delete newmod;
+ if (newhandle)
+ delete newhandle;
LastModuleError = "Unable to load " + filename_str + ": Error finding symbol: " + modexcept.GetReason();
Instance->Log(DEFAULT, LastModuleError);
return false;
}
catch (CoreException& modexcept)
{
+ DetachAll(newmod);
+ if (newmod)
+ delete newmod;
+ if (newhandle)
+ delete newhandle;
LastModuleError = "Unable to load " + filename_str + ": " + modexcept.GetReason();
Instance->Log(DEFAULT, LastModuleError);
return false;