From 9878f49dfcf6424ec50e5b9b3c46e8755a1e81fa Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Tue, 24 Sep 2002 13:24:10 -0400 Subject: fixed memory leak --- Source/cmake.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9042b4a..da5eef9 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -78,6 +78,13 @@ cmCommand *cmake::GetCommand(const char *name) void cmake::AddCommand(cmCommand* wg) { std::string name = wg->GetName(); + // if the command already exists, free the old one + RegisteredCommandsMap::iterator pos = m_Commands.find(name); + if (pos != m_Commands.end()) + { + delete pos->second; + m_Commands.erase(pos); + } m_Commands.insert( RegisteredCommandsMap::value_type(name, wg)); } -- cgit v0.12