diff --git a/core/src/avm2/activation.rs b/core/src/avm2/activation.rs index 90eccc44f..30d1c3bc9 100644 --- a/core/src/avm2/activation.rs +++ b/core/src/avm2/activation.rs @@ -2186,7 +2186,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { let value2 = self.pop_stack().coerce_to_i32(self)?; let value1 = self.pop_stack().coerce_to_i32(self)?; - self.push_stack(value1 + value2); + self.push_stack(value1.wrapping_add(value2)); Ok(FrameControl::Continue) } @@ -2237,7 +2237,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { fn op_declocal_i(&mut self, index: u32) -> Result, Error<'gc>> { let value = self.local_register(index)?.coerce_to_i32(self)?; - self.set_local_register(index, value - 1)?; + self.set_local_register(index, value.wrapping_sub(1))?; Ok(FrameControl::Continue) } @@ -2253,7 +2253,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { fn op_decrement_i(&mut self) -> Result, Error<'gc>> { let value = self.pop_stack().coerce_to_i32(self)?; - self.push_stack(value - 1); + self.push_stack(value.wrapping_sub(1)); Ok(FrameControl::Continue) } @@ -2278,7 +2278,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { fn op_inclocal_i(&mut self, index: u32) -> Result, Error<'gc>> { let value = self.local_register(index)?.coerce_to_i32(self)?; - self.set_local_register(index, value + 1)?; + self.set_local_register(index, value.wrapping_add(1))?; Ok(FrameControl::Continue) } @@ -2294,7 +2294,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { fn op_increment_i(&mut self) -> Result, Error<'gc>> { let value = self.pop_stack().coerce_to_i32(self)?; - self.push_stack(value + 1); + self.push_stack(value.wrapping_add(1)); Ok(FrameControl::Continue) } @@ -2330,7 +2330,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { let value2 = self.pop_stack().coerce_to_i32(self)?; let value1 = self.pop_stack().coerce_to_i32(self)?; - self.push_stack(value1 * value2); + self.push_stack(value1.wrapping_mul(value2)); Ok(FrameControl::Continue) } @@ -2346,7 +2346,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { fn op_negate_i(&mut self) -> Result, Error<'gc>> { let value1 = self.pop_stack().coerce_to_i32(self)?; - self.push_stack(-value1); + self.push_stack(value1.wrapping_neg()); Ok(FrameControl::Continue) } @@ -2384,7 +2384,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { let value2 = self.pop_stack().coerce_to_i32(self)?; let value1 = self.pop_stack().coerce_to_i32(self)?; - self.push_stack(value1 - value2); + self.push_stack(value1.wrapping_sub(value2)); Ok(FrameControl::Continue) } diff --git a/tests/tests/swfs/from_avmplus/as3/Types/Int/wraparound/test.toml b/tests/tests/swfs/from_avmplus/as3/Types/Int/wraparound/test.toml index 29f3cef79..cf6123969 100644 --- a/tests/tests/swfs/from_avmplus/as3/Types/Int/wraparound/test.toml +++ b/tests/tests/swfs/from_avmplus/as3/Types/Int/wraparound/test.toml @@ -1,2 +1 @@ num_ticks = 1 -known_failure = true