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 @@ -2052,7 +2052,7 @@ static void zend_gc_root_tmpvars(void) {
2052
2052
}
2053
2053
2054
2054
uint32_t kind = range -> var & ZEND_LIVE_MASK ;
2055
- if (kind == ZEND_LIVE_TMPVAR ) {
2055
+ if (kind == ZEND_LIVE_TMPVAR || kind == ZEND_LIVE_LOOP ) {
2056
2056
uint32_t var_num = range -> var & ~ZEND_LIVE_MASK ;
2057
2057
zval * var = ZEND_CALL_VAR (ex , var_num );
2058
2058
if (Z_REFCOUNTED_P (var )) {
You can’t perform that action at this time.
0 commit comments