File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #67111: Memory leak when using "continue 2" inside two foreach loops
3
+ --FILE--
4
+ <?php
5
+
6
+ $ array1 = [1 , 2 , 3 ];
7
+ $ array2 = [1 , 2 , 3 ];
8
+
9
+ foreach ($ array1 as $ x ) {
10
+ foreach ($ array2 as $ y ) {
11
+ echo "$ x. $ y \n" ;
12
+ continue 2 ;
13
+ }
14
+ }
15
+
16
+ ?>
17
+ --EXPECT--
18
+ 1.1
19
+ 2.1
20
+ 3.1
Original file line number Diff line number Diff line change @@ -189,11 +189,10 @@ void zend_optimizer_pass2(zend_op_array *op_array)
189
189
int nest_levels ;
190
190
int dont_optimize = 0 ;
191
191
192
- if (ZEND_OP2_TYPE (opline ) != IS_CONST ) {
193
- break ;
194
- }
195
- convert_to_long (& ZEND_OP2_LITERAL (opline ));
196
- nest_levels = ZEND_OP2_LITERAL (opline ).value .lval ;
192
+ ZEND_ASSERT (ZEND_OP2_TYPE (opline ) == IS_CONST );
193
+ ZEND_ASSERT (Z_TYPE (ZEND_OP2_LITERAL (opline )) == IS_LONG );
194
+
195
+ nest_levels = Z_LVAL (ZEND_OP2_LITERAL (opline ));
197
196
198
197
array_offset = ZEND_OP1 (opline ).opline_num ;
199
198
while (1 ) {
@@ -204,8 +203,7 @@ void zend_optimizer_pass2(zend_op_array *op_array)
204
203
jmp_to = & op_array -> brk_cont_array [array_offset ];
205
204
array_offset = jmp_to -> parent ;
206
205
if (-- nest_levels > 0 ) {
207
- if (opline -> opcode == ZEND_BRK &&
208
- op_array -> opcodes [jmp_to -> brk ].opcode == ZEND_FREE ) {
206
+ if (op_array -> opcodes [jmp_to -> brk ].opcode == ZEND_FREE ) {
209
207
dont_optimize = 1 ;
210
208
break ;
211
209
}
You can’t perform that action at this time.
0 commit comments