mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Memory Leak] Fix leak of CommandRecords in commandlist (#2244)
* Fix leak of CommandRecords in commandlist Quicker than porting to std::unique_ptr since we do fun stuff with commandlist ... * Fix leak so it won't double free This is fine enough until we rewrite it to be better
This commit is contained in:
parent
b4d5e807e3
commit
2910073373
@ -52,6 +52,7 @@ int (*command_dispatch)(Client *,std::string) = command_notavail;
|
||||
|
||||
std::map<std::string, CommandRecord *> commandlist;
|
||||
std::map<std::string, std::string> commandaliases;
|
||||
std::vector<CommandRecord *> command_delete_list;
|
||||
|
||||
/*
|
||||
* command_notavail
|
||||
@ -466,6 +467,9 @@ int command_init(void)
|
||||
*/
|
||||
void command_deinit(void)
|
||||
{
|
||||
for (auto &c : command_delete_list)
|
||||
delete c;
|
||||
command_delete_list.clear();
|
||||
commandlist.clear();
|
||||
commandaliases.clear();
|
||||
|
||||
@ -517,6 +521,7 @@ int command_add(std::string command_name, std::string description, uint8 admin,
|
||||
|
||||
commandlist[command_name] = c;
|
||||
commandaliases[command_name] = command_name;
|
||||
command_delete_list.push_back(c);
|
||||
command_count++;
|
||||
|
||||
return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user