diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 5d7949308a303..b919501c0dd25 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -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; diff --git a/ext/spl/tests/gh17198.phpt b/ext/spl/tests/gh17198.phpt new file mode 100644 index 0000000000000..8bc652d49ef4a --- /dev/null +++ b/ext/spl/tests/gh17198.phpt @@ -0,0 +1,17 @@ +--TEST-- +GH-17198 (SplFixedArray assertion failure with get_object_vars) +--FILE-- +{0} = []; +var_dump(get_object_vars($array)); +?> +--EXPECT-- +array(1) { + [0]=> + array(0) { + } +}