From f2bb41acd7cc0b36a07516c224623fba1779fef7 Mon Sep 17 00:00:00 2001 From: ndossche Date: Mon, 9 Nov 2026 16:05:15 +0100 Subject: [PATCH] Reflection: Fix trampoline leak when object construction fails for lazy object --- ext/reflection/php_reflection.c | 1 + ...onClass_makeLazyGhost_no_trampoline_leak.phpt | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 ext/reflection/tests/ReflectionClass_makeLazyGhost_no_trampoline_leak.phpt 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-- +newLazyGhost([new Helper, 'foo']); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} +?> +--EXPECT-- +Cannot make instance of internal class lazy: ReflectionClass is internal