[php-src] PHP-8.5: Reflection: Fix trampoline leak when object construction fails for lazy object

From: Date: Mon, 09 Nov 2026 17:45:12 +0000
Subject: [php-src] PHP-8.5: Reflection: Fix trampoline leak when object construction fails for lazy object
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143491@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-11-09T18:43:20+01:00 Commit: https://github.com/php/php-src/commit/62a96e1791ee2329b7ae268a6d8f18452e7ea21f Raw diff: https://github.com/php/php-src/commit/62a96e1791ee2329b7ae268a6d8f18452e7ea21f.diff Reflection: Fix trampoline leak when object construction fails for lazy object Closes GH-25342. Changed paths: A ext/reflection/tests/ReflectionClass_makeLazyGhost_no_trampoline_leak.phpt M NEWS M ext/reflection/php_reflection.c Diff: diff --git a/NEWS b/NEWS index 100a5cddcbe2..facc4a1d0031 100644 --- a/NEWS +++ b/NEWS @@ -55,6 +55,10 @@ PHP NEWS . Fixed incorrect handling of non-ASCII pending_input bytes in readline_info(), which could cause readline() to return false prematurely. (Weilin Du) +- Reflection: + . Fix trampoline leak when object construction fails for lazy object. + (ndossche) + - Streams: . Fixed bug GH-22063 (Stream filter chain UAF on self-removal during callback). (Ilia Alshanetsky) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 2c94a6e80d18..c0a8b11e0cf7 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -5415,6 +5415,7 @@ void reflection_class_new_lazy(INTERNAL_FUNCTION_PARAMETERS, strategy | options); if (!obj) { + zend_release_fcall_info_cache(&fcc); RETURN_THROWS(); } diff --git a/ext/reflection/tests/ReflectionClass_makeLazyGhost_no_trampoline_leak.phpt b/ext/reflection/tests/ReflectionClass_makeLazyGhost_no_trampoline_leak.phpt new file mode 100644 index 000000000000..dee9b56e5cdd --- /dev/null +++ b/ext/reflection/tests/ReflectionClass_makeLazyGhost_no_trampoline_leak.phpt @@ -0,0 +1,16 @@ +--TEST-- +ReflectionClass::makeLazyGhost() no trampoline leak +--FILE-- +<?php +class Helper { + public function __call($name, $args) {} +} + +try { + (new ReflectionClass('ReflectionClass'))->newLazyGhost([new Helper, 'foo']); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} +?> +--EXPECT-- +Cannot make instance of internal class lazy: ReflectionClass is internal

« previous php.cvs (#143491) next »