mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
Fix GH-8176: Fix leaking enum values in property initializers
This commit is contained in:
parent
4b90eef9cf
commit
cbbf3502a2
3
NEWS
3
NEWS
@ -2,6 +2,9 @@ PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 8.1.5
|
||||
|
||||
- Core:
|
||||
. Fixed bug GH-8176 (Enum values in property initializers leak). (Bob)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug GH-8115 (Can't catch arg type deprecation when instantiating Intl
|
||||
classes). (ilutov)
|
||||
|
23
Zend/tests/enum/gh8176.phpt
Normal file
23
Zend/tests/enum/gh8176.phpt
Normal file
@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Enum object in property initializer
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class AClass
|
||||
{
|
||||
public $prop = AnEnum::Value;
|
||||
}
|
||||
|
||||
enum AnEnum
|
||||
{
|
||||
case Value;
|
||||
}
|
||||
|
||||
var_dump(new AClass);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
object(AClass)#2 (1) {
|
||||
["prop"]=>
|
||||
enum(AnEnum::Value)
|
||||
}
|
@ -329,6 +329,18 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)
|
||||
ZVAL_UNDEF(&c->value);
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
/* properties may contain objects as well */
|
||||
if (ce->default_properties_table) {
|
||||
zval *p = ce->default_properties_table;
|
||||
zval *end = p + ce->default_properties_count;
|
||||
|
||||
while (p != end) {
|
||||
i_zval_ptr_dtor(p);
|
||||
ZVAL_UNDEF(p);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
|
||||
|
Loading…
Reference in New Issue
Block a user