mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:55:07 +02:00
Fixed panic on math with large durations (#3669)
* Output error when ls into a file without permission * math sqrt * added test to check fails when ls into prohibited dir * fix lint * math sqrt with tests and doc * trigger wasm build * Update filesystem_shell.rs * Fix Running echo .. starts printing integers forever * Fixed panic on operations with very large durations Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
This commit is contained in:
@ -289,7 +289,17 @@ impl Primitive {
|
||||
.expect("Internal error: conversion from u32 failed"),
|
||||
);
|
||||
let secs = match secs.to_i64() {
|
||||
Some(secs) => secs,
|
||||
//The duration crate doesnt accept seconds bigger than i64::MAX / 1000
|
||||
Some(secs) => match secs.checked_mul(1000) {
|
||||
Some(_) => secs,
|
||||
None => {
|
||||
return Err(ShellError::labeled_error(
|
||||
"Internal duration conversion overflow.",
|
||||
"duration overflow",
|
||||
span,
|
||||
))
|
||||
}
|
||||
},
|
||||
None => {
|
||||
return Err(ShellError::labeled_error(
|
||||
"Internal duration conversion overflow.",
|
||||
|
Reference in New Issue
Block a user