diff options
author | Brad King <brad.king@kitware.com> | 2021-03-17 13:14:46 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-03-17 13:14:55 (GMT) |
commit | 432de16343d8b2c774b24eb5cd15f9e9742499a3 (patch) | |
tree | d9917aa489eff35bc6076db354cb4c93b0fec1fd /Source/cmCMakePresetsFile.cxx | |
parent | ac4f83d98fd1c55e94736999d88effd50d2c0b64 (diff) | |
parent | bc663dc333be2aed47927d12575144e65b1e5f9d (diff) | |
download | CMake-432de16343d8b2c774b24eb5cd15f9e9742499a3.zip CMake-432de16343d8b2c774b24eb5cd15f9e9742499a3.tar.gz CMake-432de16343d8b2c774b24eb5cd15f9e9742499a3.tar.bz2 |
Merge topic 'dev/safreed/invalidconfigurepreset'
bc663dc333 Merge branch 'master' into invalid-configure-preset
b9eb3541cf Tests: update tests to catch invalid configurePreset at read-time
83eeeff7dc Fail at read-time if configurePreset field invalid
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5912
Diffstat (limited to 'Source/cmCMakePresetsFile.cxx')
-rw-r--r-- | Source/cmCMakePresetsFile.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index 7726927..c73ca9a 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -1470,8 +1470,11 @@ cmCMakePresetsFile::ReadProjectPresetsInternal(bool allowNoFiles) if (!it.second.Unexpanded.Hidden) { const auto configurePreset = this->ConfigurePresets.find(it.second.Unexpanded.ConfigurePreset); - if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true) && - configurePreset != this->ConfigurePresets.end()) { + if (configurePreset == this->ConfigurePresets.end()) { + return ReadFileResult::INVALID_CONFIGURE_PRESET; + } + + if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true)) { it.second.Unexpanded.Environment.insert( configurePreset->second.Unexpanded.Environment.begin(), configurePreset->second.Unexpanded.Environment.end()); @@ -1487,8 +1490,11 @@ cmCMakePresetsFile::ReadProjectPresetsInternal(bool allowNoFiles) if (!it.second.Unexpanded.Hidden) { const auto configurePreset = this->ConfigurePresets.find(it.second.Unexpanded.ConfigurePreset); - if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true) && - configurePreset != this->ConfigurePresets.end()) { + if (configurePreset == this->ConfigurePresets.end()) { + return ReadFileResult::INVALID_CONFIGURE_PRESET; + } + + if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true)) { it.second.Unexpanded.Environment.insert( configurePreset->second.Unexpanded.Environment.begin(), configurePreset->second.Unexpanded.Environment.end()); @@ -1541,6 +1547,8 @@ const char* cmCMakePresetsFile::ResultToString(ReadFileResult result) case ReadFileResult::BUILD_TEST_PRESETS_UNSUPPORTED: return "File version must be 2 or higher for build and test preset " "support."; + case ReadFileResult::INVALID_CONFIGURE_PRESET: + return "Invalid \"configurePreset\" field"; case ReadFileResult::INSTALL_PREFIX_UNSUPPORTED: return "File version must be 3 or higher for installDir preset " "support."; |