Skip to content

Commit 5e9273a

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-16908: _ZendTestMagicCallForward does not handle references well
2 parents 288776e + 43a3bd0 commit 5e9273a

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

ext/zend_test/test.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,9 +1108,12 @@ static ZEND_METHOD(_ZendTestMagicCallForward, __call)
11081108

11091109
ZEND_IGNORE_VALUE(arguments);
11101110

1111-
zval func;
1111+
zval func, rv;
11121112
ZVAL_STR(&func, name);
1113-
call_user_function(NULL, NULL, &func, return_value, 0, NULL);
1113+
call_user_function(NULL, NULL, &func, &rv, 0, NULL);
1114+
1115+
ZVAL_COPY_DEREF(return_value, &rv);
1116+
zval_ptr_dtor(&rv);
11141117
}
11151118

11161119
PHP_INI_BEGIN()

ext/zend_test/tests/gh16908.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-16908 (_ZendTestMagicCallForward does not handle references well)
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
$cls = new _ZendTestMagicCallForward();
8+
function &foo() {
9+
}
10+
$cls->foo()->x ??= 42;
11+
?>
12+
--EXPECTF--
13+
Notice: Only variable references should be returned by reference in %s on line %d
14+
15+
Notice: Only variable references should be returned by reference in %s on line %d
16+
17+
Fatal error: Uncaught Error: Attempt to assign property "x" on null in %s:%d
18+
Stack trace:
19+
#0 {main}
20+
thrown in %s on line %d

0 commit comments

Comments
 (0)