Skip to content

Commit 52ae641

Browse files
committed
Fixed GH-8044 (var_export/debug_zval_dump HT_ASSERT_RC1 debug failure for SplFixedArray)
1 parent 912608d commit 52ae641

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ext/spl/spl_fixedarray.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ static HashTable* spl_fixedarray_object_get_properties(zend_object *obj)
207207
if (!spl_fixedarray_empty(&intern->array)) {
208208
zend_long j = zend_hash_num_elements(ht);
209209

210+
if (GC_REFCOUNT(ht) > 1) {
211+
intern->std.properties = zend_array_dup(ht);
212+
if (!(GC_FLAGS(ht) & GC_IMMUTABLE)) {
213+
GC_DELREF(ht);
214+
}
215+
}
210216
for (zend_long i = 0; i < intern->array.size; i++) {
211217
zend_hash_index_update(ht, i, &intern->array.elements[i]);
212218
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)