Skip to content

Fix mis-compilation of by-reference nullsafe operator #11540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Zend/tests/oss_fuzz_60011_1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--TEST--
oss-fuzz #60011 (Incorrect order of instruction with nullsafe operator)
--FILE--
<?php
[&$y]=$y->y?->y;
?>
--EXPECTF--
Fatal error: Cannot take reference of a nullsafe chain in %s on line %d
8 changes: 8 additions & 0 deletions Zend/tests/oss_fuzz_60011_2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--TEST--
oss-fuzz #60011 (Incorrect order of instruction with nullsafe operator)
--FILE--
<?php
[&$y]=$y?->y->y;
?>
--EXPECTF--
Fatal error: Cannot take reference of a nullsafe chain in %s on line %d
3 changes: 3 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3257,6 +3257,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);
Expand Down