mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-18 08:51:52 +08:00
foreach: Fix crash parsing integer out of range
This commit is contained in:
@@ -365,6 +365,12 @@ bool TryParseInteger(cmExecutionStatus& status, const std::string& str, int& i)
|
|||||||
status.SetError(e.str());
|
status.SetError(e.str());
|
||||||
cmSystemTools::SetFatalErrorOccured();
|
cmSystemTools::SetFatalErrorOccured();
|
||||||
return false;
|
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;
|
return true;
|
||||||
|
@@ -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-2)
|
||||||
run_cmake(foreach-RANGE-non-int-test-3-3)
|
run_cmake(foreach-RANGE-non-int-test-3-3)
|
||||||
run_cmake(foreach-RANGE-invalid-test)
|
run_cmake(foreach-RANGE-invalid-test)
|
||||||
|
run_cmake(foreach-RANGE-out-of-range-test)
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
1
|
@@ -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\)$
|
@@ -0,0 +1,3 @@
|
|||||||
|
foreach(a RANGE 10000000000000000000)
|
||||||
|
break()
|
||||||
|
endforeach()
|
Reference in New Issue
Block a user