Skip to content

Commit dc03108

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix leaked parent property default value
2 parents 0a90dd6 + c35e391 commit dc03108

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Zend/tests/oss-fuzz-474613951.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
OSS-Fuzz #474613951: Leaked parent property default value
3+
--FILE--
4+
<?php
5+
6+
class A {
7+
public $prop = C { get => $this->prop; }
8+
}
9+
10+
class B extends A {
11+
public $prop { get => 42; }
12+
}
13+
14+
?>
15+
===DONE===
16+
--EXPECT--
17+
===DONE===

Zend/zend_inheritance.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,10 +1515,9 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
15151515
}
15161516

15171517
int parent_num = OBJ_PROP_TO_NUM(parent_info->offset);
1518+
/* Don't keep default properties in GC (they may be freed by opcache) */
1519+
zval_ptr_dtor_nogc(&(ce->default_properties_table[parent_num]));
15181520
if (child_info->offset != ZEND_VIRTUAL_PROPERTY_OFFSET) {
1519-
/* Don't keep default properties in GC (they may be freed by opcache) */
1520-
zval_ptr_dtor_nogc(&(ce->default_properties_table[parent_num]));
1521-
15221521
if (use_child_prop) {
15231522
ZVAL_UNDEF(&ce->default_properties_table[parent_num]);
15241523
} else {

0 commit comments

Comments
 (0)