We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 47cf683 commit 6f8ad6fCopy full SHA for 6f8ad6f
crates/vm/src/stdlib/thread.rs
@@ -1096,7 +1096,17 @@ pub(crate) mod _thread {
1096
let timeout_duration = match timeout.flatten() {
1097
Some(t) => {
1098
let secs = t.to_secs_f64();
1099
- (secs >= 0.0).then(|| Duration::from_secs_f64(secs))
+ if secs >= 0.0 {
1100
+ let nanos = secs * 1_000_000_000.0;
1101
+ if secs > TIMEOUT_MAX || nanos < 0.0 || !nanos.is_finite() {
1102
+ return Err(vm.new_overflow_error(
1103
+ "timestamp too large to convert to Rust Duration".to_owned(),
1104
+ ));
1105
+ }
1106
+ Some(Duration::from_secs_f64(secs))
1107
+ } else {
1108
+ None
1109
1110
}
1111
_ => None,
1112
};
0 commit comments