1
0
mirror of https://github.com/nushell/nushell.git synced 2025-07-15 13:55:26 +02:00

Prevent panic on date overflow ()

# Description
Fixes  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

@ -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;