summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-06-12 11:36:00 -0400
committerBrad King <brad.king@kitware.com>2014-06-12 11:36:00 -0400
commita03dbf10430a34bf9cd08f70ba5225423bcd25f7 (patch)
tree3af2fda03129b07eb8133da0804f320d2666f5a0
parent55d6aa36a522f2dd7849ccd53d9e743a88f8c7a1 (diff)
parentfe44f057f200619702e42e472b3e18612eaa359f (diff)
downloadcmake-a03dbf10430a34bf9cd08f70ba5225423bcd25f7.tar.gz
Merge branch 'backport-fix-read-after-free' into release
-rw-r--r--Source/cmake.cxx18
1 files changed, 13 insertions, 5 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 7cbc1dab43..fafcca8d2d 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -339,16 +339,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.c_str());
+ bool haveValue = false;
+ std::string cachedValue;
+ if(this->WarnUnusedCli)
+ {
+ if(const char *v = this->CacheManager->GetCacheValue(var.c_str()))
+ {
+ haveValue = true;
+ cachedValue = v;
+ }
+ }
this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
"No help, variable specified on the command line.", type);
+
if(this->WarnUnusedCli)
{
- if (!cachedValue
- || strcmp(this->CacheManager->GetCacheValue(var.c_str()),
- cachedValue) != 0)
+ if (!haveValue ||
+ cachedValue != this->CacheManager->GetCacheValue(var.c_str()))
{
this->WatchUnusedCli(var.c_str());
}