diff options
author | Brad King <brad.king@kitware.com> | 2020-10-07 11:25:43 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-10-07 11:25:52 (GMT) |
commit | c4c86acaac41a1e85bd5700d505e9470b88c9026 (patch) | |
tree | 1b3b7a2ebfdfb8544669fdc52b3d4e512ddc0ed3 /Source | |
parent | c61f820a7fb1b191fe5591805f7e53fc52424f93 (diff) | |
parent | a395cb516bacb43d082075779055b88c646e2e80 (diff) | |
download | CMake-c4c86acaac41a1e85bd5700d505e9470b88c9026.zip CMake-c4c86acaac41a1e85bd5700d505e9470b88c9026.tar.gz CMake-c4c86acaac41a1e85bd5700d505e9470b88c9026.tar.bz2 |
Merge topic 'cmake-presets-empty-var'
a395cb516b CMakePresets.json: Prohibit empty variable names
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5339
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCMakePresetsFile.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index 25997fd..90a0faa 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -305,6 +305,13 @@ ReadFileResult VisitPreset(std::map<std::string, UnexpandedPreset>& presets, cycleStatus[preset.Name] = CycleStatus::InProgress; + if (preset.CacheVariables.count("") != 0) { + return ReadFileResult::INVALID_PRESET; + } + if (preset.Environment.count("") != 0) { + return ReadFileResult::INVALID_PRESET; + } + for (auto const& i : preset.Inherits) { auto parent = presets.find(i); if (parent == presets.end()) { @@ -550,7 +557,7 @@ bool ExpandMacro(const cmCMakePresetsFile& file, } } - if (macroNamespace == "env") { + if (macroNamespace == "env" && !macroName.empty()) { auto v = preset.Environment.find(macroName); if (v != preset.Environment.end() && v->second) { if (!VisitEnv(file, preset, envCycles, *v->second, @@ -563,6 +570,9 @@ bool ExpandMacro(const cmCMakePresetsFile& file, } if (macroNamespace == "env" || macroNamespace == "penv") { + if (macroName.empty()) { + return false; + } const char* value = std::getenv(macroName.c_str()); if (value) { out += value; |