From 8095fb6079c3416cf2aa0147154f440466a6e11d Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sun, 2 Dec 2012 19:59:42 +0100 Subject: Fix DLLManager leak when an exception is thrown in init() This also caused the dlopen()'d library to stay open forever --- src/modmanager_dynamic.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/modmanager_dynamic.cpp') 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::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(); -- cgit v1.2.3