Skip to content
Snippets Groups Projects
Commit 0412b55b authored by Ben McMorran's avatar Ben McMorran Committed by Brad King
Browse files

foreach: Fix crash parsing integer out of range

parent ac487f87
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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)
1
^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\)$
foreach(a RANGE 10000000000000000000)
break()
endforeach()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment