Skip to content

Commit 639bcb4

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents 0b614a6 + c39d448 commit 639bcb4

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
@@ -8,6 +8,10 @@ PHP NEWS
88
. Fixed OSS Fuzz #62294 (Unsetting variable after ++/-- on string variable
99
warning). (Girgias)
1010

11+
- Core:
12+
. Fixed bug GH-12207 (memory leak when class using trait with doc block).
13+
(rioderelfte)
14+
1115
- Filter:
1216
. Fix explicit FILTER_REQUIRE_SCALAR with FILTER_CALLBACK (ilutov)
1317

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
@@ -4332,6 +4332,9 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z
43324332
(property_info_ptr->flags & ZEND_ACC_STATIC) != 0) {
43334333
property_info->offset = property_info_ptr->offset;
43344334
zval_ptr_dtor(&ce->default_static_members_table[property_info->offset]);
4335+
if (property_info_ptr->doc_comment) {
4336+
zend_string_release(property_info_ptr->doc_comment);
4337+
}
43354338
zend_hash_del(&ce->properties_info, name);
43364339
} else {
43374340
property_info->offset = ce->default_static_members_count++;
@@ -4350,6 +4353,9 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z
43504353
(property_info_ptr->flags & ZEND_ACC_STATIC) == 0) {
43514354
property_info->offset = property_info_ptr->offset;
43524355
zval_ptr_dtor(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]);
4356+
if (property_info_ptr->doc_comment) {
4357+
zend_string_release_ex(property_info_ptr->doc_comment, 1);
4358+
}
43534359
zend_hash_del(&ce->properties_info, name);
43544360

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

0 commit comments

Comments
 (0)