mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix duplicate dynamic properties in hooked object iterator properties table
This commit is contained in:
commit
f11d9b522d
2 changed files with 25 additions and 2 deletions
20
Zend/tests/property_hooks/oss-fuzz-382922236.phpt
Normal file
20
Zend/tests/property_hooks/oss-fuzz-382922236.phpt
Normal file
|
@ -0,0 +1,20 @@
|
|||
--TEST--
|
||||
OSS-Fuzz #382922236: Duplicate dynamic properties in hooked object iterator properties table
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
#[AllowDynamicProperties]
|
||||
class C {
|
||||
public $a {
|
||||
get => 42;
|
||||
}
|
||||
}
|
||||
|
||||
$obj = new C();
|
||||
$b = &$obj->b;
|
||||
unset($b);
|
||||
echo json_encode($obj);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
{"a":42,"b":null}
|
|
@ -44,7 +44,9 @@ static uint32_t zho_num_backed_props(zend_object *zobj)
|
|||
static zend_array *zho_build_properties_ex(zend_object *zobj, bool check_access, bool force_ptr, bool include_dynamic_props)
|
||||
{
|
||||
zend_class_entry *ce = zobj->ce;
|
||||
zend_array *properties = zend_new_array(ce->default_properties_count);
|
||||
zend_array *properties = zend_new_array(include_dynamic_props && zobj->properties
|
||||
? zend_hash_num_elements(zobj->properties)
|
||||
: ce->default_properties_count);
|
||||
zend_hash_real_init_mixed(properties);
|
||||
|
||||
/* Build list of parents */
|
||||
|
@ -105,7 +107,8 @@ skip_property:
|
|||
zend_string *prop_name;
|
||||
zval *prop_value;
|
||||
ZEND_HASH_FOREACH_STR_KEY_VAL_FROM(zobj->properties, prop_name, prop_value, zho_num_backed_props(zobj)) {
|
||||
Z_TRY_ADDREF_P(_zend_hash_append(properties, prop_name, prop_value));
|
||||
zval *tmp = _zend_hash_append(properties, prop_name, prop_value);
|
||||
Z_TRY_ADDREF_P(tmp);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue