Skip to content

Commit a833937

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix double-compilation of arrow-function
2 parents 66555a9 + 060df83 commit a833937

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PHP NEWS
1212
. Fixed bug GH-11601 (Incorrect handling of unwind and graceful exit
1313
exceptions). (ilutov)
1414
. Added zend_call_stack_get implementation for OpenBSD. (David Carlier)
15+
. Fixed oss-fuzz #60411 (Fix double-compilation of arrow-functions). (ilutov)
1516

1617
- LDAP:
1718
. Deprecate calling ldap_connect() with separate hostname and port.

Zend/tests/oss_fuzz_60441.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
oss-fuzz #60441 (Double compilation of arrow function)
3+
--FILE--
4+
<?php
5+
assert(fn()=>y)[y]??=y;
6+
?>
7+
--EXPECTF--
8+
Fatal error: Uncaught Error: Undefined constant "y" in %s:%d
9+
Stack trace:
10+
#0 {main}
11+
thrown in %s on line %d

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7613,7 +7613,7 @@ static void zend_compile_func_decl(znode *result, zend_ast *ast, bool toplevel)
76137613
zend_compile_closure_uses(uses_ast);
76147614
}
76157615

7616-
if (ast->kind == ZEND_AST_ARROW_FUNC) {
7616+
if (ast->kind == ZEND_AST_ARROW_FUNC && decl->child[2]->kind != ZEND_AST_RETURN) {
76177617
bool needs_return = true;
76187618
if (op_array->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
76197619
zend_arg_info *return_info = CG(active_op_array)->arg_info - 1;

0 commit comments

Comments
 (0)