Prevent panic on date overflow (#12427)

# Description
Fixes #12095 where date math using `chrono` can panic on overflow. It
looks like there's only one place that needed fixing.
This commit is contained in:
Ian Manske 2024-04-06 15:16:49 +00:00 committed by GitHub
parent 03667bdf8c
commit fe99729cdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -336,7 +336,17 @@ pub fn run_seq_dates(
} }
} }
ret.push(Value::string(date_string, call_span)); ret.push(Value::string(date_string, call_span));
next += step_size; if let Some(n) = next.checked_add_signed(step_size) {
next = n;
} else {
return Err(ShellError::GenericError {
error: "date overflow".into(),
msg: "adding the increment overflowed".into(),
span: Some(call_span),
help: None,
inner: vec![],
});
}
if is_out_of_range(next) { if is_out_of_range(next) {
break; break;