diff options
author | Brad King <brad.king@kitware.com> | 2014-06-12 15:36:00 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-06-12 15:36:00 (GMT) |
commit | a03dbf10430a34bf9cd08f70ba5225423bcd25f7 (patch) | |
tree | 3af2fda03129b07eb8133da0804f320d2666f5a0 | |
parent | 55d6aa36a522f2dd7849ccd53d9e743a88f8c7a1 (diff) | |
parent | fe44f057f200619702e42e472b3e18612eaa359f (diff) | |
download | CMake-a03dbf10430a34bf9cd08f70ba5225423bcd25f7.zip CMake-a03dbf10430a34bf9cd08f70ba5225423bcd25f7.tar.gz CMake-a03dbf10430a34bf9cd08f70ba5225423bcd25f7.tar.bz2 |
Merge branch 'backport-fix-read-after-free' into release
-rw-r--r-- | Source/cmake.cxx | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 7cbc1da..fafcca8 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()); } |