From 74c4d9d27aece9a619eaab330ad23cf4b0de2b19 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 25 Jan 2015 15:35:26 +0100 Subject: [PATCH] Take a size check outside of an inner loop. --- Source/cmSetTargetPropertiesCommand.cxx | 10 +++++----- Source/cmSetTestsPropertiesCommand.cxx | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index aeb8077f7..9a7fab2b6 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -35,15 +35,15 @@ bool cmSetTargetPropertiesCommand doingFiles = false; // now loop through the rest of the arguments, new style ++j; + if (std::distance(j, args.end()) % 2 != 0) + { + this->SetError("called with incorrect number of arguments."); + return false; + } while (j != args.end()) { propertyPairs.push_back(*j); ++j; - if(j == args.end()) - { - this->SetError("called with incorrect number of arguments."); - return false; - } propertyPairs.push_back(*j); ++j; } diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index e66d13d4c..032c78ea7 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -36,15 +36,15 @@ bool cmSetTestsPropertiesCommand doingFiles = false; // now loop through the rest of the arguments, new style ++j; + if (std::distance(j, args.end()) % 2 != 0) + { + this->SetError("called with incorrect number of arguments."); + return false; + } while (j != args.end()) { propertyPairs.push_back(*j); ++j; - if(j == args.end()) - { - this->SetError("called with incorrect number of arguments."); - return false; - } propertyPairs.push_back(*j); ++j; }