cvs: ZendEngine2 / zend_compile.c /tests bug41351.phpt bug41351_2.phpt bug41351_3.phpt

From: Date: Fri, 11 May 2007 09:38:52 +0000
Subject: cvs: ZendEngine2 / zend_compile.c /tests bug41351.phpt bug41351_2.phpt bug41351_3.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-5794@lists.php.net to get a copy of this message
tony2001 Fri May 11 09:38:52 2007 UTC Added files: /ZendEngine2/tests bug41351_2.phpt bug41351_3.phpt bug41351.phpt Modified files: /ZendEngine2 zend_compile.c Log: fix #41351 (Invalid opcode with foreach ($a[] as $b)) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.747&r2=1.748&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.747 ZendEngine2/zend_compile.c:1.748 --- ZendEngine2/zend_compile.c:1.747 Fri May 4 16:53:09 2007 +++ ZendEngine2/zend_compile.c Fri May 11 09:38:52 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.747 2007/05/04 16:53:09 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.748 2007/05/11 09:38:52 tony2001 Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -4034,7 +4034,11 @@ /* Change "write context" into "read context" */ fetch->extended_value = 0; /* reset ZEND_FE_RESET_VARIABLE */ while (fetch != end) { - (--fetch)->opcode -= 3; /* FETCH_W -> FETCH_R */ + --fetch; + if (fetch->opcode == ZEND_FETCH_DIM_W && fetch->op2.op_type == IS_UNUSED) { + zend_error(E_COMPILE_ERROR, "Cannot use [] for reading"); + } + fetch->opcode -= 3; /* FETCH_W -> FETCH_R */ } /* prevent double SWITCH_FREE */ zend_stack_top(&CG(foreach_copy_stack), (void **) &foreach_copy); http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug41351_2.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/bug41351_2.phpt +++ ZendEngine2/tests/bug41351_2.phpt --TEST-- Bug #41351 (Invalid opcode with foreach ($a[] as $b)) - 2 --FILE-- <?php $a = array(); foreach($a[]['test'] as $b) { } echo "Done\n"; ?> --EXPECTF-- Fatal error: Cannot use [] for reading in %s on line %d http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug41351_3.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/bug41351_3.phpt +++ ZendEngine2/tests/bug41351_3.phpt --TEST-- Bug #41351 (Invalid opcode with foreach ($a[] as $b)) - 3 --FILE-- <?php $a = array(); foreach($a['test'][] as $b) { } echo "Done\n"; ?> --EXPECTF-- Fatal error: Cannot use [] for reading in %s on line %d http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug41351.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/bug41351.phpt +++ ZendEngine2/tests/bug41351.phpt --TEST-- Bug #41351 (Invalid opcode with foreach ($a[] as $b)) --FILE-- <?php $a = array(); foreach($a[] as $b) { } echo "Done\n"; ?> --EXPECTF-- Fatal error: Cannot use [] for reading in %s on line %d

« previous php.zend-engine.cvs (#5794) next »