1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-17 07:11:52 +08:00

foreach: Fix crash parsing integer out of range

This commit is contained in:
Ben McMorran
2020-09-17 23:40:08 -07:00
committed by Brad King
parent ac487f870b
commit 0412b55b83
5 changed files with 15 additions and 0 deletions

View File

@@ -365,6 +365,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;

View File

@@ -19,3 +19,4 @@ run_cmake(foreach-RANGE-non-int-test-3-1)
run_cmake(foreach-RANGE-non-int-test-3-2)
run_cmake(foreach-RANGE-non-int-test-3-3)
run_cmake(foreach-RANGE-invalid-test)
run_cmake(foreach-RANGE-out-of-range-test)

View File

@@ -0,0 +1,4 @@
^CMake Error at foreach-RANGE-out-of-range-test\.cmake:[0-9]+ \(foreach\):
foreach Integer out of range: '10000000000000000000'
Call Stack \(most recent call first\):
CMakeLists\.txt:3 \(include\)$

View File

@@ -0,0 +1,3 @@
foreach(a RANGE 10000000000000000000)
break()
endforeach()