@@ -1481,24 +1481,33 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
1481
1481
/* If we added props to the child property, we use the childs slot for
1482
1482
* storage to keep the parent slot set to null. This automatically picks
1483
1483
* the slow path in the JIT. */
1484
- bool use_parent_prop = !parent_info -> hooks && child_info -> hooks ;
1484
+ bool use_child_prop = !parent_info -> hooks && child_info -> hooks ;
1485
+
1486
+ if (use_child_prop && child_info -> offset == ZEND_VIRTUAL_PROPERTY_OFFSET ) {
1487
+ child_info -> offset = OBJ_PROP_TO_OFFSET (ce -> default_properties_count );
1488
+ ce -> default_properties_count ++ ;
1489
+ ce -> default_properties_table = perealloc (ce -> default_properties_table , sizeof (zval ) * ce -> default_properties_count , ce -> type == ZEND_INTERNAL_CLASS );
1490
+ zval * property_default_ptr = & ce -> default_properties_table [OBJ_PROP_TO_NUM (child_info -> offset )];
1491
+ ZVAL_UNDEF (property_default_ptr );
1492
+ Z_PROP_FLAG_P (property_default_ptr ) = IS_PROP_UNINIT ;
1493
+ }
1485
1494
1486
1495
if (child_info -> offset != ZEND_VIRTUAL_PROPERTY_OFFSET ) {
1487
1496
int parent_num = OBJ_PROP_TO_NUM (parent_info -> offset );
1488
1497
1489
1498
/* Don't keep default properties in GC (they may be freed by opcache) */
1490
1499
zval_ptr_dtor_nogc (& (ce -> default_properties_table [parent_num ]));
1491
1500
1492
- if (use_parent_prop ) {
1501
+ if (use_child_prop ) {
1502
+ ZVAL_UNDEF (& ce -> default_properties_table [parent_num ]);
1503
+ } else {
1493
1504
int child_num = OBJ_PROP_TO_NUM (child_info -> offset );
1494
1505
ce -> default_properties_table [parent_num ] = ce -> default_properties_table [child_num ];
1495
1506
ZVAL_UNDEF (& ce -> default_properties_table [child_num ]);
1496
- } else {
1497
- ZVAL_UNDEF (& ce -> default_properties_table [parent_num ]);
1498
1507
}
1499
1508
}
1500
1509
1501
- if (use_parent_prop ) {
1510
+ if (! use_child_prop ) {
1502
1511
child_info -> offset = parent_info -> offset ;
1503
1512
}
1504
1513
child_info -> flags &= ~ZEND_ACC_VIRTUAL ;
0 commit comments