Skip to content

Commit 5eddcb3

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix propagation of ZEND_ACC_RETURN_REFERENCE for call trampoline
2 parents 7930867 + 8720063 commit 5eddcb3

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ PHP NEWS
1313
. Fixed bug GH-16168 (php 8.1 and earlier crash immediately when compiled
1414
with Xcode 16 clang on macOS 15). (nielsdos)
1515
. Fixed bug GH-16371 (Assertion failure in Zend/zend_weakrefs.c:646). (Arnaud)
16+
. Fixed bug GH-16515 (Incorrect propagation of ZEND_ACC_RETURN_REFERENCE for
17+
call trampoline). (ilutov)
1618

1719
- Curl:
1820
. Fixed bug GH-16302 (CurlMultiHandle holds a reference to CurlHandle if

Zend/tests/gh16515.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
GH-16515: Incorrect propagation of ZEND_ACC_RETURN_REFERENCE for call trampoline
3+
--FILE--
4+
<?php
5+
6+
namespace Foo;
7+
8+
class Foo {
9+
public function &__call($method, $args) {}
10+
}
11+
12+
call_user_func((new Foo)->bar(...));
13+
14+
?>
15+
--EXPECTF--
16+
Notice: Only variable references should be returned by reference in %s on line %d

Zend/zend_closures.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ void zend_closure_from_frame(zval *return_value, zend_execute_data *call) { /* {
860860

861861
memset(&trampoline, 0, sizeof(zend_internal_function));
862862
trampoline.type = ZEND_INTERNAL_FUNCTION;
863-
trampoline.fn_flags = mptr->common.fn_flags & (ZEND_ACC_STATIC | ZEND_ACC_VARIADIC);
863+
trampoline.fn_flags = mptr->common.fn_flags & (ZEND_ACC_STATIC | ZEND_ACC_VARIADIC | ZEND_ACC_RETURN_REFERENCE);
864864
trampoline.handler = zend_closure_call_magic;
865865
trampoline.function_name = mptr->common.function_name;
866866
trampoline.scope = mptr->common.scope;

Zend/zend_object_handlers.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,10 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce
13451345
func->arg_flags[0] = 0;
13461346
func->arg_flags[1] = 0;
13471347
func->arg_flags[2] = 0;
1348-
func->fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE | ZEND_ACC_PUBLIC | ZEND_ACC_VARIADIC;
1348+
func->fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE
1349+
| ZEND_ACC_PUBLIC
1350+
| ZEND_ACC_VARIADIC
1351+
| (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE);
13491352
if (is_static) {
13501353
func->fn_flags |= ZEND_ACC_STATIC;
13511354
}

0 commit comments

Comments
 (0)