Skip to content

Commit d568337

Browse files
committed
Fix OSS-Fuzz #69765: Yield reference to nullsafe chain
You cannot return or yield a reference to a nullsafe chain. This was checked already in zend_compile_return but not yet in zend_compile_yield. Closes GH-14716.
1 parent c03196a commit d568337

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88
. Fixed bug GH-14626 (Fix is_zend_ptr() for huge blocks). (Arnaud)
99
. Fixed bug GH-14590 (Memory leak in FPM test gh13563-conf-bool-env.phpt.
1010
(nielsdos)
11+
. Fixed OSS-Fuzz #69765. (nielsdos)
1112

1213
- Dom:
1314
. Fixed bug GH-14702 (DOMDocument::xinclude() crash). (nielsdos)

Zend/tests/oss-fuzz-69765.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
OSS-Fuzz #69765: yield reference to nullsafe chain
3+
--FILE--
4+
<?php
5+
function &test($object) {
6+
yield $object->y?->y;
7+
}
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot take reference of a nullsafe chain in %s on line %d

Zend/zend_compile.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9329,6 +9329,10 @@ static void zend_compile_yield(znode *result, zend_ast *ast) /* {{{ */
93299329

93309330
if (value_ast) {
93319331
if (returns_by_ref && zend_is_variable(value_ast)) {
9332+
if (zend_ast_is_short_circuited(value_ast)) {
9333+
zend_error_noreturn(E_COMPILE_ERROR, "Cannot take reference of a nullsafe chain");
9334+
}
9335+
93329336
zend_compile_var(&value_node, value_ast, BP_VAR_W, 1);
93339337
} else {
93349338
zend_compile_expr(&value_node, value_ast);

0 commit comments

Comments
 (0)