Skip to content

Commit

Permalink
Merge branch 'PHP-8.4'
Browse files Browse the repository at this point in the history
* PHP-8.4:
  Fix phpGH-17198: SplFixedArray assertion failure with get_object_vars
  • Loading branch information
nielsdos committed Dec 17, 2024
2 parents e78a008 + 5f13c62 commit 4d140f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ext/spl/spl_fixedarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,14 @@ static HashTable* spl_fixedarray_object_get_properties_for(zend_object *obj, zen
zval *const elements = intern->array.elements;
HashTable *ht = zend_new_array(size);

for (zend_long i = 0; i < size; i++) {
Z_TRY_ADDREF_P(&elements[i]);
zend_hash_next_index_insert(ht, &elements[i]);
/* The array elements are not *real properties*. */
if (purpose != ZEND_PROP_PURPOSE_GET_OBJECT_VARS) {
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) {
zend_long nkey;
zend_string *skey;
Expand Down
17 changes: 17 additions & 0 deletions ext/spl/tests/gh17198.phpt
Original file line number Diff line number Diff line change
@@ -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) {
}
}

0 comments on commit 4d140f7

Please sign in to comment.