Skip to content

Commit a94216d

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix mis-compilation of by-reference nullsafe operator
2 parents 73cf12d + 54dfa86 commit a94216d

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fixed bug GH-11507 (String concatenation performance regression in 8.3).
77
(nielsdos)
8+
. Fixed oss-fuzz #60011 (Mis-compilation of by-reference nullsafe operator).
9+
(ilutov)
810

911
- DOM:
1012
. Fixed bug GH-11500 (Namespace reuse in createElementNS() generates wrong

Zend/tests/oss_fuzz_60011_1.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
oss-fuzz #60011 (Incorrect order of instruction with nullsafe operator)
3+
--FILE--
4+
<?php
5+
[&$y]=$y->y?->y;
6+
?>
7+
--EXPECTF--
8+
Fatal error: Cannot take reference of a nullsafe chain in %s on line %d

Zend/tests/oss_fuzz_60011_2.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
oss-fuzz #60011 (Incorrect order of instruction with nullsafe operator)
3+
--FILE--
4+
<?php
5+
[&$y]=$y?->y->y;
6+
?>
7+
--EXPECTF--
8+
Fatal error: Cannot take reference of a nullsafe chain in %s on line %d

Zend/zend_compile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3372,6 +3372,9 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
33723372
if (!zend_is_variable_or_call(expr_ast)) {
33733373
zend_error_noreturn(E_COMPILE_ERROR,
33743374
"Cannot assign reference to non referenceable value");
3375+
} else if (zend_ast_is_short_circuited(expr_ast)) {
3376+
zend_error_noreturn(E_COMPILE_ERROR,
3377+
"Cannot take reference of a nullsafe chain");
33753378
}
33763379

33773380
zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1);

0 commit comments

Comments
 (0)