php-src/ext/reflection/tests/bug79820.phpt
Christopher Broadbent ee7c7a8e26 Fixed bug #79820
Similar to what is done for ReflectionType itself, copy the
type name stored inside ReflectionProperty. Also make sure the
type field is always initialized for dynamic properties.

This is a non-issue in PHP 8, because we store a pointer to the
property_info there, rather than a copy.
2020-07-15 10:58:56 +02:00

23 lines
425 B
PHP

--TEST--
Bug #79820: Use after free when type duplicated into ReflectionProperty gets resolved
--FILE--
<?php
class Test {
public stdClass $prop;
}
$rp = new ReflectionProperty(Test::class, 'prop');
$test = new Test;
$test->prop = new stdClass;
var_dump($rp->getType()->getName());
$test->dynProp = 42;
$rp = new ReflectionProperty($test, 'dynProp');
var_dump($rp->getType());
?>
--EXPECT--
string(8) "stdClass"
NULL