Merge branch 'PHP-8.1' into PHP-8.2

This commit is contained in:
David Carlier 2023-09-18 17:46:11 +01:00
commit c39d4481c5
3 changed files with 31 additions and 0 deletions

4
NEWS
View file

@ -2,6 +2,10 @@ PHP NEWS
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.2.12 ?? ??? ????, PHP 8.2.12
- Core:
. Fixed bug GH-12207 (memory leak when class using trait with doc block).
(rioderelfte)
- Filter: - Filter:
. Fix explicit FILTER_REQUIRE_SCALAR with FILTER_CALLBACK (ilutov) . Fix explicit FILTER_REQUIRE_SCALAR with FILTER_CALLBACK (ilutov)

View file

@ -0,0 +1,21 @@
--TEST--
Overriding a static property where both declarations have a doc block does not leak memory
--FILE--
<?php
trait MyTrait {
/**
* trait comment
*/
static $property;
}
class MyClass {
use MyTrait;
/**
* class comment
*/
static $property;
}
?>
--EXPECT--

View file

@ -4199,6 +4199,9 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z
(property_info_ptr->flags & ZEND_ACC_STATIC) != 0) { (property_info_ptr->flags & ZEND_ACC_STATIC) != 0) {
property_info->offset = property_info_ptr->offset; property_info->offset = property_info_ptr->offset;
zval_ptr_dtor(&ce->default_static_members_table[property_info->offset]); zval_ptr_dtor(&ce->default_static_members_table[property_info->offset]);
if (property_info_ptr->doc_comment) {
zend_string_release(property_info_ptr->doc_comment);
}
zend_hash_del(&ce->properties_info, name); zend_hash_del(&ce->properties_info, name);
} else { } else {
property_info->offset = ce->default_static_members_count++; property_info->offset = ce->default_static_members_count++;
@ -4217,6 +4220,9 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z
(property_info_ptr->flags & ZEND_ACC_STATIC) == 0) { (property_info_ptr->flags & ZEND_ACC_STATIC) == 0) {
property_info->offset = property_info_ptr->offset; property_info->offset = property_info_ptr->offset;
zval_ptr_dtor(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]); zval_ptr_dtor(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]);
if (property_info_ptr->doc_comment) {
zend_string_release_ex(property_info_ptr->doc_comment, 1);
}
zend_hash_del(&ce->properties_info, name); zend_hash_del(&ce->properties_info, name);
ZEND_ASSERT(ce->type == ZEND_INTERNAL_CLASS); ZEND_ASSERT(ce->type == ZEND_INTERNAL_CLASS);