Skip to content

Commit 05a5878

Browse files
Lord-McSweeneyLord-McSweeney
authored andcommitted
avm2: Fix incorrect optimization for constructsuper when receiver is possibly null
1 parent 8566bcf commit 05a5878

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

core/src/avm2/optimizer/optimize.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,17 +1516,24 @@ fn abstract_interpret_ops<'gc>(
15161516
stack.popn(activation, num_args)?;
15171517

15181518
// Then receiver.
1519-
stack.pop(activation)?;
1519+
let receiver = stack.pop(activation)?;
15201520

15211521
// Remove `super()` calls in classes that extend Object, since they
15221522
// are noops anyway.
15231523
if num_args == 0 {
15241524
let object_class = activation.avm2().classes().object;
1525+
// TODO: A `None` `bound_superclass_object` should throw
1526+
// a VerifyError
15251527
if activation
15261528
.bound_superclass_object()
15271529
.is_some_and(|c| c == object_class)
15281530
{
1529-
optimize_op_to!(Op::Pop);
1531+
// When the receiver is null, this op can still throw an
1532+
// error, so let's ensure it's guaranteed nonnull before
1533+
// optimizing it
1534+
if receiver.not_null(activation) {
1535+
optimize_op_to!(Op::Pop);
1536+
}
15301537
}
15311538
}
15321539
}

0 commit comments

Comments
 (0)