mirror of
https://github.com/php/php-src.git
synced 2026-10-29 02:07:35 +08:00
ReflectionMethod::__construct() overwrote intern->ptr without releasing the previous Closure::__invoke() trampoline, and ReflectionClassConstant::__construct() overwrote the $name and $class slots without dropping their previous references. ReflectionFunction, ReflectionParameter and ReflectionProperty already release prior state on re-entry. Closes GH-22968
29 lines
528 B
PHP
29 lines
528 B
PHP
--TEST--
|
|
ReflectionMethod double construct call on Closure::__invoke() does not leak
|
|
--FILE--
|
|
<?php
|
|
|
|
function test(ReflectionMethod $r) {
|
|
$r->__construct(function () {}, '__invoke');
|
|
}
|
|
|
|
$r = new ReflectionMethod(function () {}, '__invoke');
|
|
for ($i = 0; $i < 10; $i++) {
|
|
test($r);
|
|
}
|
|
|
|
$before = memory_get_usage();
|
|
for ($i = 0; $i < 1000; $i++) {
|
|
test($r);
|
|
}
|
|
$after = memory_get_usage();
|
|
|
|
var_dump($before === $after);
|
|
var_dump($r->name, $r->class);
|
|
|
|
?>
|
|
--EXPECT--
|
|
bool(true)
|
|
string(8) "__invoke"
|
|
string(7) "Closure"
|