From 1ce3ec636af42a550b3384b17c2c93099932122a Mon Sep 17 00:00:00 2001 From: Lord-McSweeney Date: Fri, 24 Nov 2023 20:56:25 -0800 Subject: [PATCH] avm2: Prevent `AVM1Movie`s from being moved around in the DO hierarchy --- .../flash/display/display_object_container.rs | 8 ++++++++ tests/tests/swfs/avm2/mixed_avm/output.txt | 2 ++ tests/tests/swfs/avm2/mixed_avm/test.swf | Bin 657 -> 776 bytes 3 files changed, 10 insertions(+) diff --git a/core/src/avm2/globals/flash/display/display_object_container.rs b/core/src/avm2/globals/flash/display/display_object_container.rs index 0e041f6fc7fd..87171d1aa8ca 100644 --- a/core/src/avm2/globals/flash/display/display_object_container.rs +++ b/core/src/avm2/globals/flash/display/display_object_container.rs @@ -50,6 +50,14 @@ fn validate_add_operation<'gc>( )?)); } + if !proposed_child.movie().is_action_script_3() { + return Err(Error::AvmError(argument_error( + activation, + "Error #2180: It is illegal to move AVM1 content (AS1 or AS2) to a different part of the displayList when it has been loaded into AVM2 (AS3) content.", + 2180, + )?)); + } + if DisplayObject::ptr_eq(proposed_child, new_parent) { return Err(Error::AvmError(argument_error( activation, diff --git a/tests/tests/swfs/avm2/mixed_avm/output.txt b/tests/tests/swfs/avm2/mixed_avm/output.txt index 3713b4f86585..0228487f4849 100644 --- a/tests/tests/swfs/avm2/mixed_avm/output.txt +++ b/tests/tests/swfs/avm2/mixed_avm/output.txt @@ -3,4 +3,6 @@ hello from avm1! [object AVM1Movie] [object ApplicationDomain] Load complete! +2180 +ArgumentError onmousedown at 10, 10! diff --git a/tests/tests/swfs/avm2/mixed_avm/test.swf b/tests/tests/swfs/avm2/mixed_avm/test.swf index 1843017e8a7d4f322ea0ff4e9ca57f309d638921..65d3ebdb3f4526af44e7c279c7b59057cd127a4d 100644 GIT binary patch literal 776 zcmV+j1NZzxS5py(1ONbdoPAW`ZqrB*o>|9PJ8|N;ZQPJH&_a%KX-SqtLZZ@1EeTYu zS|X@8?vSFhn`{~*Cl2yyb0vCe>u3fAGiY^X1hnPd0*%U!KugFzBerleK#642VOMw-FMl;Y3K=V zcTzV^ZU+*8KR`d5!b-^B+k^|vJssa`MsJ5!U&@rMY5wkH7?dPSve3R4$p{ZMd4yA+3$7-xDx`W& z|EaUw>D2f7uJD3MCm73yi!s&8zcs7KONYV@<*6U9_%hOLHZ$>Ttk;uGNGjDxxW|$| z41PSqUE<|!#tYEyNQ(h4nI zqhy(q8qMC&R|qAml-#7`HYIl`ty3b$kNO>=mx9n99Gy8Db0~AN%u$(>k>gjWrPl~|B!QAKOn!lNfD2qhc-i=iark&< zjj=c9|9PJ8|N;P2J+QG=V@7RE`T04}EG$5NcJ3 z)QZ1{2)oIK7&&(8Y*TpaQ8)ot;0k%+963T+$3O@mR%`9dH#6USvkJ`Kj>nRO<^f!=ed_B$0zLkf{nPE zvW1K*-gvNUk1l&gN5~YcY5rl@i%NoJ*67$Di3p1oafQQxaVF1TnG5xd{-`s&;V|$! z9`~cL84bk1#e}Nzv!;rybjrP0-1_@UAR@MHXOdHUP@DaPS*4+%Nn~kFGP9<(O01%# zTP4e|maJto630~? zS8-hGxLL=Q9XBKP8`w-&AD;;VLh||Q6l(zOB{$z&ZY|-=(0k>XxpP|_B9TZWUwAul zrnn6-MH5R?TqDNo``?_&Auw!fM;csd0~BU)XZ@&%SH%Hg7+_D|xw((65)ou~1X+TK rkF-{>olBfnPBb8SKn)5&iXe#za?->RUG-%Y!_MCf>