Skip to content

Commit ed280f1

Browse files
committed
Fix leaked parent property default value
Fixes OSS-Fuzz #474613951
1 parent f61b1fc commit ed280f1

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

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)