[php-src] master: Merge branch 'PHP-8.5'
| From: | Ilia Alshanetsky | Date: | Tue, 22 Sep 2026 01:26:17 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141358@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-09-21T21:16:11-04:00
Commit: https://github.com/php/php-src/commit/7dc859d75f50b0c20d6924272dbcb84055cd97cb
Raw diff: https://github.com/php/php-src/commit/7dc859d75f50b0c20d6924272dbcb84055cd97cb.diff
Merge branch 'PHP-8.5'
* PHP-8.5:
Zend: release the trampoline when zend_call_function() bails early
Changed paths:
A Zend/tests/call_function_trampoline_leak.phpt
M Zend/zend_execute_API.c
Diff:
diff --git a/Zend/tests/call_function_trampoline_leak.phpt
b/Zend/tests/call_function_trampoline_leak.phpt
new file mode 100644
index 000000000000..bdf8f257d956
--- /dev/null
+++ b/Zend/tests/call_function_trampoline_leak.phpt
@@ -0,0 +1,36 @@
+--TEST--
+zend_call_function() must release the trampoline when it bails before the call
+--FILE--
+<?php
+
+class A {
+ #[\Deprecated]
+ public function __call($func, $args) {
+ }
+}
+
+set_error_handler(function ($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+// Indirect call so that the callable is resolved by zend_call_function()
+// rather than by the ZEND_INIT_USER_CALL handler, which frees the trampoline
+// itself.
+$call = 'call_user_func_array';
+
+try {
+ $call([new A(), 'foo'], []);
+} catch (Exception $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+ $call([Closure::fromCallable('strcmp'), '__invoke'], ['string2'
=> 'b']);
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Exception: Method A::foo() is deprecated
+ArgumentCountError: Closure::__invoke(): Argument #1 ($string1) not passed
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index ac1683bb368f..59fb717b5d28 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -875,6 +875,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_
zend_deprecated_function(func);
if (UNEXPECTED(EG(exception))) {
+ zend_release_fcall_info_cache(fci_cache);
if (pinned_this) {
OBJ_RELEASE(pinned_this);
}
@@ -1022,6 +1023,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache
*fci_
if (zend_handle_undef_args(call) == FAILURE) {
zend_vm_stack_free_args(call);
zend_vm_stack_free_call_frame(call);
+ zend_release_fcall_info_cache(fci_cache);
if (pinned_this) {
OBJ_RELEASE(pinned_this);
}