[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using enum objects in property initializers leaks #8176

Closed
bwoebi opened this issue Mar 7, 2022 · 0 comments
Closed

Using enum objects in property initializers leaks #8176

bwoebi opened this issue Mar 7, 2022 · 0 comments

Comments

@bwoebi
Copy link
Member
bwoebi commented Mar 7, 2022

Description

<?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 default property table of AClass, but objects are freed before default 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

PHP 8.1 / master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@cmb69 @bwoebi and others