diff options
author | Ken Martin <ken.martin@kitware.com> | 2005-06-22 18:16:18 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2005-06-22 18:16:18 (GMT) |
commit | de89c6fa69beb86f1067834326c91e333d3ce4aa (patch) | |
tree | 6aa6f7d0221ea82576a53dfc9a453d259c36bbbf /Source/cmForEachCommand.cxx | |
parent | 6e6bfc752bef548fefa6bec2b117e45039712aa2 (diff) | |
download | CMake-de89c6fa69beb86f1067834326c91e333d3ce4aa.zip CMake-de89c6fa69beb86f1067834326c91e333d3ce4aa.tar.gz CMake-de89c6fa69beb86f1067834326c91e333d3ce4aa.tar.bz2 |
COMP: fix possible poroblem with freed memory
Diffstat (limited to 'Source/cmForEachCommand.cxx')
-rw-r--r-- | Source/cmForEachCommand.cxx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 3ae244e..e4a12cb 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -34,7 +34,11 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) if(!expandedArguments.empty() && (expandedArguments[0] == m_Args[0])) { // store the old value - const char *oldDef = mf.GetDefinition(m_Args[0].c_str()); + std::string oldDef; + if (mf.GetDefinition(m_Args[0].c_str())) + { + oldDef = mf.GetDefinition(m_Args[0].c_str()); + } m_Executing = true; std::vector<std::string>::const_iterator j = m_Args.begin(); ++j; @@ -52,7 +56,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) } } // restore the variable to its prior value - mf.AddDefinition(m_Args[0].c_str(),oldDef); + mf.AddDefinition(m_Args[0].c_str(),oldDef.c_str()); mf.RemoveFunctionBlocker(lff); return true; } |