php-src/Zend/tests/gh10169.phpt
Ilija Tovilo 47ed1904ef
Fix use-after-free in write_property when object is released
Fixes GH-10169
Closes GH-10179
2023-02-02 20:03:50 +01:00

38 lines
615 B
PHP

--TEST--
GH-10169: Fix use-after-free when releasing object during property assignment
--FILE--
<?php
class A
{
public string $prop;
}
class B
{
public function __toString()
{
global $a;
$a = null;
return str_repeat('a', 1);
}
}
$a = new A();
try {
$a->prop = new B();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
$a = new A();
$a->prop = '';
try {
$a->prop = new B();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Object was released while assigning to property A::$prop
Object was released while assigning to property A::$prop