Skip to content

Commit c39d448

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
2 parents f4f34b6 + 910f579 commit c39d448

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.2.12
44

5+
- Core:
6+
. Fixed bug GH-12207 (memory leak when class using trait with doc block).
7+
(rioderelfte)
8+
59
- Filter:
610
. Fix explicit FILTER_REQUIRE_SCALAR with FILTER_CALLBACK (ilutov)
711

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Overriding a static property where both declarations have a doc block does not leak memory
3+
--FILE--
4+
<?php
5+
trait MyTrait {
6+
/**
7+
* trait comment
8+
*/
9+
static $property;
10+
}
11+
12+
class MyClass {
13+
use MyTrait;
14+
15+
/**
16+
* class comment
17+
*/
18+
static $property;
19+
}
20+
?>
21+
--EXPECT--

Zend/zend_API.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4199,6 +4199,9 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z
41994199
(property_info_ptr->flags & ZEND_ACC_STATIC) != 0) {
42004200
property_info->offset = property_info_ptr->offset;
42014201
zval_ptr_dtor(&ce->default_static_members_table[property_info->offset]);
4202+
if (property_info_ptr->doc_comment) {
4203+
zend_string_release(property_info_ptr->doc_comment);
4204+
}
42024205
zend_hash_del(&ce->properties_info, name);
42034206
} else {
42044207
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
42174220
(property_info_ptr->flags & ZEND_ACC_STATIC) == 0) {
42184221
property_info->offset = property_info_ptr->offset;
42194222
zval_ptr_dtor(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]);
4223+
if (property_info_ptr->doc_comment) {
4224+
zend_string_release_ex(property_info_ptr->doc_comment, 1);
4225+
}
42204226
zend_hash_del(&ce->properties_info, name);
42214227

42224228
ZEND_ASSERT(ce->type == ZEND_INTERNAL_CLASS);

0 commit comments

Comments
 (0)