From ae99ad29fc2fa184884997728a2bdc453476c89e 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 -> 651 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..483cc9ba2c25b --- /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(4.5, 5.5); +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..0a52f3c4b47d74118a3c79226ca71f78f7269bbc GIT binary patch literal 651 zcmV;60(AXaS5q>k0{{Se0ssJA001BW06YKujv4yj=Vl0?JwAo?b#KsqVJOXhixy4a z1v37mOh!q!duw(1D_l1z3z0VgHxB9Y;ryOt+H4UaGwq-bc5tB0m@amJ@Zeci1_!QZnT84W^-kDu!b~qNjlRVSVp3_xhTH3JNC+2)1J*>=-p>|kv2*_BK)@TdzxW~s5 zRX~U5S-?);A+G44YL3M0*f=<)^i{biPBGOIR$lYO&{zPAusrYQ+MNi=aD#T4!$ zPkS*y6Mr~&jb2>K)qny&rD&(ESY3$E?lK{?1zUms&{I3Vb0+e_VuJ%g*!>e*m8J?242(Fwy)sIf>4Gx4!fXex2Yta>q0V? z{I@BC>}PHhswF~dy&Mv9ZHF=O9$ z@cd<(K#igZe^FDG?nBga`Nz5tQDRXRO<$l*k$pFK3LBFmyEa~uEvNRVzp~jqcn2aC zwPkC38;~?v)6*%3d8yYsj!~cl^jvDDZ^lyk@gWV=oboYT?fKhLf0buFuGGKH{Z@xZ z;f=cY^DzT3vDA100*b)Zte8!Qd~92#7k4>N#6mmak^~#V5fIDM*ALwY21oUb`RJkO z*^#GMq<3m@%6k%>km#!aga%R!2*omeW`4D&8bC>7|NHn0+4#q_0iiqWSW>VRt#D2V zBpXO!i5n~SvVb-<;r=ou0Mkqp6ZZ7@Fv!AxjyZmTK&QQBt=+h$z0HpJK0GQ7XETKY l4Tm