diff --git a/NEWS b/NEWS index a14b29d1b63..cd0bc930df1 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ PHP NEWS - Core: . Fixed bug GH-11507 (String concatenation performance regression in 8.3). (nielsdos) + . Fixed oss-fuzz #60011 (Mis-compilation of by-reference nullsafe operator). + (ilutov) - DOM: . Fixed bug GH-11500 (Namespace reuse in createElementNS() generates wrong diff --git a/Zend/tests/oss_fuzz_60011_1.phpt b/Zend/tests/oss_fuzz_60011_1.phpt new file mode 100644 index 00000000000..cb55b32a5bc --- /dev/null +++ b/Zend/tests/oss_fuzz_60011_1.phpt @@ -0,0 +1,8 @@ +--TEST-- +oss-fuzz #60011 (Incorrect order of instruction with nullsafe operator) +--FILE-- +y?->y; +?> +--EXPECTF-- +Fatal error: Cannot take reference of a nullsafe chain in %s on line %d diff --git a/Zend/tests/oss_fuzz_60011_2.phpt b/Zend/tests/oss_fuzz_60011_2.phpt new file mode 100644 index 00000000000..8c6880e358e --- /dev/null +++ b/Zend/tests/oss_fuzz_60011_2.phpt @@ -0,0 +1,8 @@ +--TEST-- +oss-fuzz #60011 (Incorrect order of instruction with nullsafe operator) +--FILE-- +y->y; +?> +--EXPECTF-- +Fatal error: Cannot take reference of a nullsafe chain in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 21fc22e7314..ced2b5ec91a 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3372,6 +3372,9 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */ if (!zend_is_variable_or_call(expr_ast)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot assign reference to non referenceable value"); + } else if (zend_ast_is_short_circuited(expr_ast)) { + zend_error_noreturn(E_COMPILE_ERROR, + "Cannot take reference of a nullsafe chain"); } zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1);