Skip to content

Commit 461db52

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents e4ecadc + 589542f commit 461db52

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Zend/tests/gc_042.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Object properties HT may need to be removed from nested data
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
public function __destruct() {
8+
$GLOBALS['x'] = $this;
9+
}
10+
}
11+
12+
$t = new Test;
13+
$t->x = new stdClass;
14+
$t->x->t = $t;
15+
$a = (array) $t->x;
16+
unset($t, $a);
17+
gc_collect_cycles();
18+
var_dump($x);
19+
20+
?>
21+
--EXPECT--
22+
object(Test)#1 (1) {
23+
["x"]=>
24+
object(stdClass)#2 (1) {
25+
["t"]=>
26+
*RECURSION*
27+
}
28+
}

Zend/zend_gc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,10 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
14001400
ref = Z_COUNTED_P(zv);
14011401
goto tail_call;
14021402
}
1403+
if (GC_REF_ADDRESS(ht) != 0 && GC_REF_CHECK_COLOR(ht, GC_BLACK)) {
1404+
GC_TRACE_REF(ht, "removing from buffer");
1405+
GC_REMOVE_FROM_BUFFER(ht);
1406+
}
14031407
} else {
14041408
return;
14051409
}

0 commit comments

Comments
 (0)