summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2002-09-24 17:24:10 (GMT)
committerKen Martin <ken.martin@kitware.com>2002-09-24 17:24:10 (GMT)
commit9878f49dfcf6424ec50e5b9b3c46e8755a1e81fa (patch)
treec6593fffe4ff076b151fc2014ff5192c466a013d /Source/cmake.cxx
parent72054b95fdac6013a042cfee433eb474757a1450 (diff)
downloadCMake-9878f49dfcf6424ec50e5b9b3c46e8755a1e81fa.zip
CMake-9878f49dfcf6424ec50e5b9b3c46e8755a1e81fa.tar.gz
CMake-9878f49dfcf6424ec50e5b9b3c46e8755a1e81fa.tar.bz2
fixed memory leak
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx7
1 files changed, 7 insertions, 0 deletions
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));
}