Skip to content

Commit 54dfa86

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix mis-compilation of by-reference nullsafe operator
2 parents ac60c5c + dc73b73 commit 54dfa86

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ PHP NEWS
88
- CLI:
99
. Fix interrupted CLI output causing the process to exit. (nielsdos)
1010

11+
- Core:
12+
. Fixed oss-fuzz #60011 (Mis-compilation of by-reference nullsafe operator).
13+
(ilutov)
14+
1115
- Date:
1216
. Fixed bug GH-11368 (Date modify returns invalid datetime). (Derick)
1317

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
@@ -3264,6 +3264,9 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
32643264
if (!zend_is_variable_or_call(expr_ast)) {
32653265
zend_error_noreturn(E_COMPILE_ERROR,
32663266
"Cannot assign reference to non referenceable value");
3267+
} else if (zend_ast_is_short_circuited(expr_ast)) {
3268+
zend_error_noreturn(E_COMPILE_ERROR,
3269+
"Cannot take reference of a nullsafe chain");
32673270
}
32683271

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

0 commit comments

Comments
 (0)