Skip to content

Commit a584d12

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fixed GH-8044 (var_export/debug_zval_dump HT_ASSERT_RC1 debug failure for SplFixedArray)
2 parents 73fed0f + 52ae641 commit a584d12

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ext/spl/spl_fixedarray.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ static HashTable* spl_fixedarray_object_get_properties(zend_object *obj)
214214
if (!spl_fixedarray_empty(&intern->array)) {
215215
zend_long j = zend_hash_num_elements(ht);
216216

217+
if (GC_REFCOUNT(ht) > 1) {
218+
intern->std.properties = zend_array_dup(ht);
219+
GC_TRY_DELREF(ht);
220+
}
217221
for (zend_long i = 0; i < intern->array.size; i++) {
218222
zend_hash_index_update(ht, i, &intern->array.elements[i]);
219223
Z_TRY_ADDREF(intern->array.elements[i]);

ext/spl/tests/fixedarray_022.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
SPL: FixedArray: Bug GH-8044 (var_export/debug_zval_dump HT_ASSERT_RC1 debug failure for SplFixedArray)
3+
--FILE--
4+
<?php
5+
call_user_func(function () {
6+
$x = new SplFixedArray(1);
7+
$x[0] = $x;
8+
var_export($x); echo "\n";
9+
debug_zval_dump($x); echo "\n";
10+
});
11+
?>
12+
--EXPECTF--
13+
Warning: var_export does not handle circular references in %s on line 5
14+
SplFixedArray::__set_state(array(
15+
0 => NULL,
16+
))
17+
object(SplFixedArray)#2 (1) refcount(4){
18+
[0]=>
19+
*RECURSION*
20+
}

0 commit comments

Comments
 (0)