Skip to content

Commit 4bfaf54

Browse files
committed
Fix leaked parent property default value
Fixes OSS-Fuzz #474613951 Closes phpGH-20911
1 parent b273fc7 commit 4bfaf54

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88
. Fix OSS-Fuzz #471533782 (Infinite loop in GC destructor fiber). (ilutov)
99
. Fix OSS-Fuzz #472563272 (Borked block_pass JMP[N]Z optimization). (ilutov)
1010
. Fixed bug GH-GH-20914 (Internal enums can be cloned and compared). (Arnaud)
11+
. Fix OSS-Fuzz #474613951 (Leaked parent property default value). (ilutov)
1112

1213
- MbString:
1314
. Fixed bug GH-20833 (mb_str_pad() divide by zero if padding string is

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
@@ -1495,10 +1495,9 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
14951495
}
14961496

14971497
int parent_num = OBJ_PROP_TO_NUM(parent_info->offset);
1498+
/* Don't keep default properties in GC (they may be freed by opcache) */
1499+
zval_ptr_dtor_nogc(&(ce->default_properties_table[parent_num]));
14981500
if (child_info->offset != ZEND_VIRTUAL_PROPERTY_OFFSET) {
1499-
/* Don't keep default properties in GC (they may be freed by opcache) */
1500-
zval_ptr_dtor_nogc(&(ce->default_properties_table[parent_num]));
1501-
15021501
if (use_child_prop) {
15031502
ZVAL_UNDEF(&ce->default_properties_table[parent_num]);
15041503
} else {

0 commit comments

Comments
 (0)