mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
fix: 添加 vm 循环次数上限以避免测试死循环
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user