mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 22:30:13 -06:00
Merge topic 'fix-read-after-free'
5b2c2d2fMerge branch 'backport-fix-read-after-free' into fix-read-after-free23ffb72acmake: Fix read-after-free while checking command-line argumentsfe44f057cmake: Fix read-after-free while checking command-line arguments
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user