summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-06-13 19:45:07 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-06-13 19:45:07 (GMT)
commitd7bbfa41f64c8183d30fa5cf9acc8490de0edebd (patch)
tree2d9b10f7e9f3a57a2239d1e98f7f71ea0d9b380f
parent38befe399837e28cce9decb09e68cd5e4afe90d5 (diff)
parent5b2c2d2fda62208d9e65b86e2fa7e4467c431088 (diff)
downloadCMake-d7bbfa41f64c8183d30fa5cf9acc8490de0edebd.zip
CMake-d7bbfa41f64c8183d30fa5cf9acc8490de0edebd.tar.gz
CMake-d7bbfa41f64c8183d30fa5cf9acc8490de0edebd.tar.bz2
Merge topic 'fix-read-after-free'
5b2c2d2f Merge branch 'backport-fix-read-after-free' into fix-read-after-free 23ffb72a cmake: Fix read-after-free while checking command-line arguments fe44f057 cmake: Fix read-after-free while checking command-line arguments
-rw-r--r--Source/cmake.cxx18
1 files changed, 13 insertions, 5 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index e3bebbd..86d3766 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -343,16 +343,24 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
// The value is transformed if it is a filepath for example, so
// we can't compare whether the value is already in the cache until
// after we call AddCacheEntry.
- const char *cachedValue =
- this->CacheManager->GetCacheValue(var);
+ bool haveValue = false;
+ std::string cachedValue;
+ if(this->WarnUnusedCli)
+ {
+ if(const char *v = this->CacheManager->GetCacheValue(var))
+ {
+ haveValue = true;
+ cachedValue = v;
+ }
+ }
this->CacheManager->AddCacheEntry(var, value.c_str(),
"No help, variable specified on the command line.", type);
+
if(this->WarnUnusedCli)
{
- if (!cachedValue
- || strcmp(this->CacheManager->GetCacheValue(var),
- cachedValue) != 0)
+ if (!haveValue ||
+ cachedValue != this->CacheManager->GetCacheValue(var))
{
this->WatchUnusedCli(var);
}