[php-src] Issue #8176: Using enum objects in property initializers leaks
| From: | bwoebi | Date: | Mon, 07 Mar 2022 01:51:47 +0000 |
| Subject: | [php-src] Issue #8176: Using enum objects in property initializers leaks | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-240237@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8176
Author: bwoebi
### Description
```php
<?php
enum AnEnum
{
case Value;
}
class AClass
{
public $prop = AnEnum::Value;
}
var_dump(new AClass);
```
leaks the
AnEnum::Value enum object.
The reason is that the enum object gets stored in the property table of AClass, but
objects are freed before property tables are destroyed:
- zend_objects_store_free_object_storage does an addref, as the object is not released
yet
- destroy_zend_class reduces refcount when freeing default properties, but too late,
it's (obviously) called after object storage freeing.
### PHP Version
master
### Operating System
_No response_