Skip to content

Commit

Permalink
avm1: tellTarget on an undefined object targets the base clip in SWF6-
Browse files Browse the repository at this point in the history
  • Loading branch information
n0samu authored and adrian17 committed Sep 23, 2023
1 parent dc53758 commit e8bbb21
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion core/src/avm1/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,12 @@ impl<'a, 'gc> Activation<'a, 'gc> {
return self.set_target(&target);
}
Value::Undefined => {
self.set_target_clip(None);
// In SWF6 and below, SetTarget2 on an undefined object resets the target to the base clip
if self.swf_version() > 6 {
self.set_target_clip(None);
} else {
self.set_target_clip(Some(base_clip));
}
}
Value::Object(o) => {
if let Some(clip) = o.as_display_object() {
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/swfs/avm1/tell_target_invalid/output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Target not found: Target="dummy" Base="_level0.mc"
/tellTarget('dummy') { gotoAndPlay(n); }
pass
/tellTarget(undefined) { gotoAndPlay(5); }
/tellTarget(undefined) { gotoAndStop(5); }
/tellTarget(undefined) { gotoAndPlay(n); }
pass
Binary file modified tests/tests/swfs/avm1/tell_target_invalid/test.fla
Binary file not shown.
Binary file modified tests/tests/swfs/avm1/tell_target_invalid/test.swf
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/tests/swfs/avm1/tell_target_invalid_swf6/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Target not found: Target="dummy" Base="_level0.mc"
/tellTarget('dummy') { gotoAndPlay(n); }
pass
/tellTarget(undefined) { gotoAndStop(5); }
This should only be reached in SWF6 and below
Binary file not shown.
3 changes: 3 additions & 0 deletions tests/tests/swfs/avm1/tell_target_invalid_swf6/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This test was compiled from the same source as `tell_target_invalid`.
# The header was edited to SWF version 6 using JPEXS FFDec.
num_frames = 5

0 comments on commit e8bbb21

Please sign in to comment.