fix: 溢出钳位消灭 slice 与 Date 族引擎 panic

This commit is contained in:
2026-09-20 17:52:34 +00:00
parent 3fb3ebc3cc
commit 06cd63c3b0
4 changed files with 456 additions and 233 deletions
@@ -35,6 +35,11 @@ fn normalize_index<H: VmHost>(vm: &mut H, value: JsValue, len: usize) -> usize {
if n.is_nan() {
return 0;
}
// ToIntegerOrInfinity:±Infinity 不截断,负无穷归 0、正无穷归 len,
// 避免饱和成 isize::MIN 后取负溢出。
if n.is_infinite() {
return if n < 0.0 { 0 } else { len };
}
let int = n.trunc() as isize;
if int < 0 {
len.saturating_sub((-int) as usize)