[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Tue, 22 Sep 2026 01:26:15 +0000
Subject: [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141357@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-09-21T21:07:25-04:00 Commit: https://github.com/php/php-src/commit/027a634280a1fa9eb8c2c7ada7176b9b6b8e85d3 Raw diff: https://github.com/php/php-src/commit/027a634280a1fa9eb8c2c7ada7176b9b6b8e85d3.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: 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 a74cfa759430..0014cfce2d27 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -865,6 +865,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ if (UNEXPECTED(EG(exception))) { zend_vm_stack_free_call_frame(call); + zend_release_fcall_info_cache(fci_cache); return SUCCESS; } } @@ -981,6 +982,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); return SUCCESS; } }

« previous php.cvs (#141357) next »