Merge topic 'foreach-int-parse-range-check'

0412b55b83 foreach: Fix crash parsing integer out of range

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5239
This commit is contained in:
Brad King
2020-09-21 12:55:21 +00:00
committed by Kitware Robot
5 changed files with 15 additions and 0 deletions
+6
View File
@@ -366,6 +366,12 @@ bool TryParseInteger(cmExecutionStatus& status, const std::string& str, int& i)
status.SetError(e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
} catch (std::out_of_range&) {
std::ostringstream e;
e << "Integer out of range: '" << str << "'";
status.SetError(e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
return true;