From 74d5edf5b00c376be9c3767cfeb8194ed8507209 Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Sat, 6 Jun 2026 23:43:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=20vm=20=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=AC=A1=E6=95=B0=E4=B8=8A=E9=99=90=E4=BB=A5=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E6=B5=8B=E8=AF=95=E6=AD=BB=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_vm/src/vm.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/oxide_vm/src/vm.rs b/crates/oxide_vm/src/vm.rs index 3fd8b803..85085f4c 100644 --- a/crates/oxide_vm/src/vm.rs +++ b/crates/oxide_vm/src/vm.rs @@ -176,7 +176,13 @@ impl Vm { } fn dispatch(&mut self) -> Result { + 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()); }