Skip to content

Commit 4d140f7

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-17198: SplFixedArray assertion failure with get_object_vars
2 parents e78a008 + 5f13c62 commit 4d140f7

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

ext/spl/spl_fixedarray.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,14 @@ static HashTable* spl_fixedarray_object_get_properties_for(zend_object *obj, zen
239239
zval *const elements = intern->array.elements;
240240
HashTable *ht = zend_new_array(size);
241241

242-
for (zend_long i = 0; i < size; i++) {
243-
Z_TRY_ADDREF_P(&elements[i]);
244-
zend_hash_next_index_insert(ht, &elements[i]);
242+
/* The array elements are not *real properties*. */
243+
if (purpose != ZEND_PROP_PURPOSE_GET_OBJECT_VARS) {
244+
for (zend_long i = 0; i < size; i++) {
245+
Z_TRY_ADDREF_P(&elements[i]);
246+
zend_hash_next_index_insert(ht, &elements[i]);
247+
}
245248
}
249+
246250
if (source_properties && zend_hash_num_elements(source_properties) > 0) {
247251
zend_long nkey;
248252
zend_string *skey;

ext/spl/tests/gh17198.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
GH-17198 (SplFixedArray assertion failure with get_object_vars)
3+
--FILE--
4+
<?php
5+
#[AllowDynamicProperties]
6+
class MySplFixedArray extends SplFixedArray {
7+
}
8+
$array = new MySplFixedArray(2);
9+
$array->{0} = [];
10+
var_dump(get_object_vars($array));
11+
?>
12+
--EXPECT--
13+
array(1) {
14+
[0]=>
15+
array(0) {
16+
}
17+
}

0 commit comments

Comments
 (0)