Skip to content

Commit 43a3bd0

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-16908: _ZendTestMagicCallForward does not handle references well
2 parents 053af52 + d9fada4 commit 43a3bd0

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
@@ -1114,9 +1114,12 @@ static ZEND_METHOD(_ZendTestMagicCallForward, __call)
11141114

11151115
ZEND_IGNORE_VALUE(arguments);
11161116

1117-
zval func;
1117+
zval func, rv;
11181118
ZVAL_STR(&func, name);
1119-
call_user_function(NULL, NULL, &func, return_value, 0, NULL);
1119+
call_user_function(NULL, NULL, &func, &rv, 0, NULL);
1120+
1121+
ZVAL_COPY_DEREF(return_value, &rv);
1122+
zval_ptr_dtor(&rv);
11201123
}
11211124

11221125
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)