From 2910073373b082a06b2f688b3b2e9a1a1e55cb82 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" <277429+mackal@users.noreply.github.com> Date: Mon, 6 Jun 2022 15:21:35 -0400 Subject: [PATCH] [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 --- zone/command.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zone/command.cpp b/zone/command.cpp index b8914e593..8d15f9960 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -52,6 +52,7 @@ int (*command_dispatch)(Client *,std::string) = command_notavail; std::map commandlist; std::map commandaliases; +std::vector 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;