mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-17198: SplFixedArray assertion failure with get_object_vars
This commit is contained in:
@@ -239,10 +239,14 @@ static HashTable* spl_fixedarray_object_get_properties_for(zend_object *obj, zen
|
|||||||
zval *const elements = intern->array.elements;
|
zval *const elements = intern->array.elements;
|
||||||
HashTable *ht = zend_new_array(size);
|
HashTable *ht = zend_new_array(size);
|
||||||
|
|
||||||
for (zend_long i = 0; i < size; i++) {
|
/* The array elements are not *real properties*. */
|
||||||
Z_TRY_ADDREF_P(&elements[i]);
|
if (purpose != ZEND_PROP_PURPOSE_GET_OBJECT_VARS) {
|
||||||
zend_hash_next_index_insert(ht, &elements[i]);
|
for (zend_long i = 0; i < size; i++) {
|
||||||
|
Z_TRY_ADDREF_P(&elements[i]);
|
||||||
|
zend_hash_next_index_insert(ht, &elements[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source_properties && zend_hash_num_elements(source_properties) > 0) {
|
if (source_properties && zend_hash_num_elements(source_properties) > 0) {
|
||||||
zend_long nkey;
|
zend_long nkey;
|
||||||
zend_string *skey;
|
zend_string *skey;
|
||||||
|
|||||||
17
ext/spl/tests/gh17198.phpt
Normal file
17
ext/spl/tests/gh17198.phpt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
--TEST--
|
||||||
|
GH-17198 (SplFixedArray assertion failure with get_object_vars)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
#[AllowDynamicProperties]
|
||||||
|
class MySplFixedArray extends SplFixedArray {
|
||||||
|
}
|
||||||
|
$array = new MySplFixedArray(2);
|
||||||
|
$array->{0} = [];
|
||||||
|
var_dump(get_object_vars($array));
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
array(1) {
|
||||||
|
[0]=>
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user