diff --git a/core/src/avm2/activation.rs b/core/src/avm2/activation.rs index 2b00d8a20..16fab4023 100644 --- a/core/src/avm2/activation.rs +++ b/core/src/avm2/activation.rs @@ -1583,7 +1583,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { vname, self.context.gc_context, )?; - let so = ScriptObject::catch_scope(self.context.gc_context, &qname); + let so = ScriptObject::catch_scope(self, &qname); self.context.avm2.push(so); } diff --git a/core/src/avm2/object/script_object.rs b/core/src/avm2/object/script_object.rs index eb93fe3aa..2466a68ea 100644 --- a/core/src/avm2/object/script_object.rs +++ b/core/src/avm2/object/script_object.rs @@ -105,17 +105,18 @@ impl<'gc> ScriptObject<'gc> { /// A special case for `newcatch` implementation. Basically a variable (q)name /// which maps to slot 1. - pub fn catch_scope(mc: MutationContext<'gc, '_>, qname: &QName<'gc>) -> Object<'gc> { + pub fn catch_scope( + activation: &mut Activation<'_, 'gc, '_>, + qname: &QName<'gc>, + ) -> Object<'gc> { let mut base = ScriptObjectData::custom_new(None, None); + let mc = activation.context.gc_context; let vt = VTable::newcatch(mc, &qname); base.set_vtable(vt); - // Compilers expect `setslot 1` to work on the `newcatch` object. - // `setslot 1` maps to index 1, so we need two slots here, because Ruffle - // maps setslot arg directly to the slot array index, unlike AVM which does the - // -1 shift. - base.install_slot(); - base.install_slot(); - ScriptObject(GcCell::allocate(mc, base)).into() + + let mut so = ScriptObject(GcCell::allocate(mc, base)); + so.install_instance_slots(activation); + so.into() } } diff --git a/core/src/avm2/vtable.rs b/core/src/avm2/vtable.rs index a56adc5a0..679917dc2 100644 --- a/core/src/avm2/vtable.rs +++ b/core/src/avm2/vtable.rs @@ -79,6 +79,10 @@ impl<'gc> VTable<'gc> { protected_namespace: None, resolved_traits: rt, method_table: vec![], + // Compilers expect `setslot 1` to work on the `newcatch` object. + // `setslot 1` maps to index 1, so we need two slots here, because Ruffle + // maps setslot arg directly to the slot array index, unlike AVM which does the + // -1 shift. default_slots: vec![None, None], slot_classes: vec![PropertyClass::Any, PropertyClass::Any], },