fix: 添加 vm 循环次数上限以避免测试死循环

This commit is contained in:
爱特每羊队
2026-06-06 23:43:05 +08:00
parent f4bb81da94
commit 0bccba0c6e
+6
View File
@@ -176,7 +176,13 @@ impl Vm {
}
fn dispatch(&mut self) -> Result<JsValue, String> {
let mut steps: u64 = 0;
const MAX_STEPS: u64 = 100_000_000;
loop {
steps += 1;
if steps > MAX_STEPS {
return Err(format!("VM step limit exceeded at pc={}", self.pc));
}
if self.pc >= self.bytecode.len() {
return Err("program counter out of bounds".into());
}