diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-13 21:34:29 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-13 21:34:29 +0000 |
commit | 37fd031da06761c8a050105b55d73a8ab499fb74 (patch) | |
tree | 6709b8882806cfe2a4dd20bdcd0aa5581344955e /src/modules.cpp | |
parent | 99064f734b9b1513c1d3b3792d6ea8102aae26e1 (diff) |
Remove Command and ModeHandler objects in their destructors; fixes possible pointer leak if a module was not careful when triggering exceptions in its constructor
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11872 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules.cpp')
-rw-r--r-- | src/modules.cpp | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index 1c4f47103..71363ae9d 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -474,9 +474,6 @@ bool ModuleManager::Unload(const char* filename) this->DetachAll(modfind->second); - ServerInstance->Parser->RemoveCommands(modfind->second); - ServerInstance->Modes->RemoveModes(modfind->second); - ServerInstance->GlobalCulls.AddItem(modfind->second); Modules.erase(modfind); @@ -495,7 +492,7 @@ bool ModuleManager::Unload(const char* filename) void ModuleManager::LoadAll() { char configToken[MAXBUF]; - ModCount = -1; + ModCount = 0; printf("\nLoading core commands"); fflush(stdout); @@ -670,24 +667,6 @@ const std::string& ModuleManager::GetModuleName(Module* m) return nothing; } -/* This is ugly, yes, but hash_map's arent designed to be - * addressed in this manner, and this is a bit of a kludge. - * Luckily its a specialist function and rarely used by - * many modules (in fact, it was specially created to make - * m_safelist possible, initially). - */ - -Channel* InspIRCd::GetChannelIndex(long index) -{ - int target = 0; - for (chan_hash::iterator n = this->chanlist->begin(); n != this->chanlist->end(); n++, target++) - { - if (index == target) - return n->second; - } - return NULL; -} - CmdResult InspIRCd::CallCommandHandler(const std::string &commandname, const std::vector<std::string>& parameters, User* user) { return this->Parser->CallHandler(commandname, parameters, user); @@ -700,10 +679,9 @@ bool InspIRCd::IsValidModuleCommand(const std::string &commandname, int pcnt, Us void InspIRCd::AddCommand(Command *f) { - if (!this->Parser->CreateCommand(f)) + if (!this->Parser->AddCommand(f)) { - ModuleException err("Command "+std::string(f->command)+" already exists."); - throw (err); + throw ModuleException("Command "+std::string(f->command)+" already exists."); } } |