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+ $ a0 , 1 ];
8+ foreach ($ aas  &$ v
9+     $ a0 ] =& $ a
10+     $ a1 ] = array ();
11+     $ a1 ][0 ] =& $ a1 ];
12+     $ b1 ;
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) {
20522052			}
20532053
20542054			uint32_t  kind  =  range -> var  &  ZEND_LIVE_MASK ;
2055- 			if  (kind  ==  ZEND_LIVE_TMPVAR ) {
2055+ 			if  (kind  ==  ZEND_LIVE_TMPVAR   ||   kind   ==   ZEND_LIVE_LOOP ) {
20562056				uint32_t  var_num  =  range -> var  &  ~ZEND_LIVE_MASK ;
20572057				zval  * var  =  ZEND_CALL_VAR (ex , var_num );
20582058				if  (Z_REFCOUNTED_P (var )) {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments