From 601f36df33efc4e2a3460ae63a8fb4c3a9daa5e4 Mon Sep 17 00:00:00 2001 From: EmperorBale Date: Thu, 8 Sep 2022 17:08:32 -0700 Subject: [PATCH] avm2: Introduce `clear_stack` & `clear_scope`. --- core/src/avm2/activation.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/avm2/activation.rs b/core/src/avm2/activation.rs index ae5910d5d..d128ce4d7 100644 --- a/core/src/avm2/activation.rs +++ b/core/src/avm2/activation.rs @@ -692,6 +692,16 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { self.avm2().pop_scope(scope_depth) } + pub fn clear_stack(&mut self) { + let stack_depth = self.stack_depth; + self.avm2().stack.truncate(stack_depth) + } + + pub fn clear_scope(&mut self) { + let scope_depth = self.scope_depth; + self.avm2().scope_stack.truncate(scope_depth) + } + /// Get the superclass of the class that defined the currently-executing /// method, if it exists. /// @@ -891,10 +901,10 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { } if matches { + self.clear_stack(); self.push_stack(error); - let scope_depth = self.scope_depth; - self.avm2().scope_stack.truncate(scope_depth); + self.clear_scope(); reader.seek_absolute(full_data, e.target_offset as usize); return Ok(FrameControl::Continue); }