[Cmake-commits] CMake branch, next, updated. v3.0.0-3697-g7f74f79
Brad King
brad.king at kitware.com
Thu Jun 12 11:35:21 EDT 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 7f74f79890c3044f0332678f8c4a0deb22692906 (commit)
via 23ffb72ab3c37652b8d6f1201a5f313cb0d4f8a6 (commit)
from 5f7231ee39e1e18c4057900048a309234ea73887 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f74f79890c3044f0332678f8c4a0deb22692906
commit 7f74f79890c3044f0332678f8c4a0deb22692906
Merge: 5f7231e 23ffb72
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Jun 12 11:35:20 2014 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Jun 12 11:35:20 2014 -0400
Merge topic 'fix-read-after-free' into next
23ffb72a cmake: Fix read-after-free while checking command-line arguments
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=23ffb72ab3c37652b8d6f1201a5f313cb0d4f8a6
commit 23ffb72ab3c37652b8d6f1201a5f313cb0d4f8a6
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Jun 12 09:46:54 2014 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Jun 12 11:24:17 2014 -0400
cmake: Fix read-after-free while checking command-line arguments
Since commit v2.8.12~300^2~1 (CLI: Suppress the unused warning if the
key value pair is cached, 2013-05-16), cmake::SetCacheArgs saves a
cachedValue pointer and may cause the memory to be freed (by setting the
cache entry) before reading it again. Fix this by saving the old value
in a separate string.
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);
}
-----------------------------------------------------------------------
Summary of changes:
Source/cmake.cxx | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list