From 2f13f0ac4eb8607118588a03472fe1c01e061071 Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Fri, 6 Sep 2024 18:02:45 +0200 Subject: [PATCH] avm2: Skip attempting to serialize methods --- core/src/avm2/amf.rs | 4 ++++ .../bytearray_method_serialization/Test.as | 19 ++++++++++++++++++ .../bytearray_method_serialization/output.txt | 1 + .../bytearray_method_serialization/test.swf | Bin 0 -> 641 bytes .../bytearray_method_serialization/test.toml | 1 + 5 files changed, 25 insertions(+) create mode 100644 tests/tests/swfs/avm2/bytearray_method_serialization/Test.as create mode 100644 tests/tests/swfs/avm2/bytearray_method_serialization/output.txt create mode 100644 tests/tests/swfs/avm2/bytearray_method_serialization/test.swf create mode 100644 tests/tests/swfs/avm2/bytearray_method_serialization/test.toml diff --git a/core/src/avm2/amf.rs b/core/src/avm2/amf.rs index 0303d6abb82aa..393d582055842 100644 --- a/core/src/avm2/amf.rs +++ b/core/src/avm2/amf.rs @@ -202,11 +202,15 @@ pub fn recursive_serialize<'gc>( ) -> Result<(), Error<'gc>> { if let Some(static_properties) = static_properties { let vtable = obj.vtable(); + // TODO: respect versioning let mut props = vtable.public_properties(); // Flash appears to use vtable iteration order, but we sort ours // to make our test output consistent. props.sort_by_key(|(name, _)| name.to_utf8_lossy().to_string()); for (name, prop) in props { + if let Property::Method { .. } = prop { + continue; + } if let Property::Virtual { get, set } = prop { if !(get.is_some() && set.is_some()) { continue; diff --git a/tests/tests/swfs/avm2/bytearray_method_serialization/Test.as b/tests/tests/swfs/avm2/bytearray_method_serialization/Test.as new file mode 100644 index 0000000000000..6853e5d032f39 --- /dev/null +++ b/tests/tests/swfs/avm2/bytearray_method_serialization/Test.as @@ -0,0 +1,19 @@ +// compiled with mxmlc (and modified to SWF v9) + +import flash.utils.ByteArray; +import flash.geom.Point; + +var p = new Point(); +var b = new ByteArray(); +b.writeObject(p); +trace(b.length); + +package { + import flash.display.MovieClip; + + public class Test extends MovieClip { + public function Test() { + return; + } + } +} diff --git a/tests/tests/swfs/avm2/bytearray_method_serialization/output.txt b/tests/tests/swfs/avm2/bytearray_method_serialization/output.txt new file mode 100644 index 0000000000000..7273c0fa8c522 --- /dev/null +++ b/tests/tests/swfs/avm2/bytearray_method_serialization/output.txt @@ -0,0 +1 @@ +25 diff --git a/tests/tests/swfs/avm2/bytearray_method_serialization/test.swf b/tests/tests/swfs/avm2/bytearray_method_serialization/test.swf new file mode 100644 index 0000000000000000000000000000000000000000..9e64a67f5d0ec3f09afe0b3ae162948b5f7dcfc9 GIT binary patch literal 641 zcmV-{0)G8NS5pa+0{{ScoL!OIZqqOr$L%Dod)&GM0WOeAxMOOZb`sL6wxhHRZ4zvv zyWnP1+{A4IIbnM}T=6!%2CuM3KwR+_!#RiwtQ_p`|M$KIblyNT#`$pTejOOW}(qrzd`*D2MlxoPka@98$Ld0E+SF4q|IyNIV z$L*7o6Kr*Gr_+*-7T<(|tXm;}VGJrwIa11)a))`bko=tHI)7pD9rII^>tO2BfQEwO zw%ImvE8$yj$W7u#Q))UDS1en3X?+6Evax_S)r%^)RgZ{zQ@f~vTkVKwwq~oB bb!hLnwl>=xCPbN<#HJm6Ehm2fr_1paemXX% literal 0 HcmV?d00001 diff --git a/tests/tests/swfs/avm2/bytearray_method_serialization/test.toml b/tests/tests/swfs/avm2/bytearray_method_serialization/test.toml new file mode 100644 index 0000000000000..dbee897f5863d --- /dev/null +++ b/tests/tests/swfs/avm2/bytearray_method_serialization/test.toml @@ -0,0 +1 @@ +num_frames = 1