diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-10-06 16:09:38 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-10-06 16:09:38 (GMT) |
commit | a395cb516bacb43d082075779055b88c646e2e80 (patch) | |
tree | 0037dafff2bf1c20db00ec4560740ba7a7e84d2f /Source/cmCMakePresetsFile.cxx | |
parent | 8c4c658ab062f2920448a02fe3a5d42fe3d48876 (diff) | |
download | CMake-a395cb516bacb43d082075779055b88c646e2e80.zip CMake-a395cb516bacb43d082075779055b88c646e2e80.tar.gz CMake-a395cb516bacb43d082075779055b88c646e2e80.tar.bz2 |
CMakePresets.json: Prohibit empty variable names
Diffstat (limited to 'Source/cmCMakePresetsFile.cxx')
-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; |