mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 18:03:51 +01:00
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:
parent
03667bdf8c
commit
fe99729cdb
@ -336,7 +336,17 @@ pub fn run_seq_dates(
|
||||
}
|
||||
}
|
||||
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) {
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user