diff options
author | Brad King <brad.king@kitware.com> | 2021-12-14 14:35:50 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-12-14 14:36:08 (GMT) |
commit | 25a300b76e88903dfa44939dd3a564b5377b4640 (patch) | |
tree | 02b3fb3b80399009438e99024895a140b6e0be53 /Source | |
parent | 7a408511bd264e49f2e94dfc74468aed87373303 (diff) | |
parent | 7dd3e99270431cace5086c62f4ee73441b9edc5e (diff) | |
download | CMake-25a300b76e88903dfa44939dd3a564b5377b4640.zip CMake-25a300b76e88903dfa44939dd3a564b5377b4640.tar.gz CMake-25a300b76e88903dfa44939dd3a564b5377b4640.tar.bz2 |
Merge topic 'fix-list-transform-invalid-index-crashes'
7dd3e99270 cmListCommand: Handle invalid FOR selector ranges
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !6786
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmListCommand.cxx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index b358327..56345df 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -678,6 +678,14 @@ public: this->Start = this->NormalizeIndex(this->Start, count); this->Stop = this->NormalizeIndex(this->Stop, count); + // Does stepping move us further from the end? + if (this->Start > this->Stop) { + throw transform_error( + cmStrCat("sub-command TRANSFORM, selector FOR " + "expects <start> to be no greater than <stop> (", + this->Start, " > ", this->Stop, ")")); + } + // compute indexes auto size = (this->Stop - this->Start + 1) / this->Step; if ((this->Stop - this->Start + 1) % this->Step != 0) { @@ -1026,9 +1034,10 @@ bool HandleTransformCommand(std::vector<std::string> const& args, } } - if (step < 0) { + if (step <= 0) { status.SetError("sub-command TRANSFORM, selector FOR expects " - "non negative numeric value for <step>."); + "positive numeric value for <step>."); + return false; } command.Selector = |