diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-12-02 19:59:42 +0100 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2012-12-02 20:34:33 +0100 |
commit | 8095fb6079c3416cf2aa0147154f440466a6e11d (patch) | |
tree | e05d66b3e61f8869baddbf518482758fa56d5766 | |
parent | eea9343393614f81169eaf9ac1fcab1db949d018 (diff) |
Fix DLLManager leak when an exception is thrown in init()
This also caused the dlopen()'d library to stay open forever
-rw-r--r-- | src/modmanager_dynamic.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/modmanager_dynamic.cpp b/src/modmanager_dynamic.cpp index 27da56c69..5406cfd33 100644 --- a/src/modmanager_dynamic.cpp +++ b/src/modmanager_dynamic.cpp @@ -94,7 +94,10 @@ bool ModuleManager::Load(const std::string& filename, bool defer) { // failure in module constructor if (newmod) + { DoSafeUnload(newmod); + ServerInstance->GlobalCulls.AddItem(newhandle); + } else delete newhandle; LastModuleError = "Unable to load " + filename + ": " + modexcept.GetReason(); @@ -228,7 +231,7 @@ void ModuleManager::LoadAll() for(std::map<std::string, Module*>::iterator i = Modules.begin(); i != Modules.end(); i++) { Module* mod = i->second; - try + try { ServerInstance->Logs->Log("MODULE", DEBUG, "Initializing %s", i->first.c_str()); mod->init(); |