]> granicus.if.org Git - php/commitdiff
Improve fix for #76046
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 27 Nov 2018 18:43:25 +0000 (19:43 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 27 Nov 2018 18:43:25 +0000 (19:43 +0100)
Also locate the JMP at the start of the foreach.

Patch suggested by Derick.

Zend/zend_compile.c

index 9c0893b773992fd9fac9585221ef29247352b3c2..ee40e9c982db275e393e133781af602e190e0150 100644 (file)
@@ -4797,6 +4797,10 @@ void zend_compile_foreach(zend_ast *ast) /* {{{ */
 
        zend_compile_stmt(stmt_ast);
 
+       /* Place JMP and FE_FREE on the line where foreach starts. It would be
+        * better to use the end line, but this information is not available
+        * currently. */
+       CG(zend_lineno) = ast->lineno;
        zend_emit_jump(opnum_fetch);
 
        opline = &CG(active_op_array)->opcodes[opnum_reset];
@@ -4807,7 +4811,6 @@ void zend_compile_foreach(zend_ast *ast) /* {{{ */
 
        zend_end_loop(opnum_fetch, &reset_node);
 
-       CG(zend_lineno) = ast->lineno;
        opline = zend_emit_op(NULL, ZEND_FE_FREE, &reset_node, NULL);
 }
 /* }}} */