File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GC 047: Leak after GC inside a foreach loop
3
+ --INI--
4
+ zend.enable_gc=1
5
+ --FILE--
6
+ <?php
7
+ $ a = [0 , 1 ];
8
+ foreach ($ a as &$ v ) {
9
+ $ a [0 ] =& $ a ;
10
+ $ a [1 ] = array ();
11
+ $ a [1 ][0 ] =& $ a [1 ];
12
+ $ b = 1 ;
13
+ $ a =& $ b ;
14
+ gc_collect_cycles ();
15
+ break ;
16
+ }
17
+ var_dump (gc_collect_cycles ());
18
+ ?>
19
+ --EXPECT--
20
+ int(2)
Original file line number Diff line number Diff line change @@ -1726,7 +1726,7 @@ static void zend_gc_root_tmpvars(void) {
1726
1726
}
1727
1727
1728
1728
uint32_t kind = range -> var & ZEND_LIVE_MASK ;
1729
- if (kind == ZEND_LIVE_TMPVAR ) {
1729
+ if (kind == ZEND_LIVE_TMPVAR || kind == ZEND_LIVE_LOOP ) {
1730
1730
uint32_t var_num = range -> var & ~ZEND_LIVE_MASK ;
1731
1731
zval * var = ZEND_CALL_VAR (ex , var_num );
1732
1732
if (Z_REFCOUNTED_P (var )) {
You can’t perform that action at this time.
0 commit comments