cvs: ZendEngine2(PHP_5_2) / zend_compile.c /tests bug41351.phpt bug41351_2.phpt bug41351_3.phpt
| From: | Antony Dovgal | Date: | Fri, 11 May 2007 09:39:36 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_2) / 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-5795@lists.php.net to get a copy of this message | ||
tony2001 Fri May 11 09:39:36 2007 UTC
Added files: (Branch: PHP_5_2)
/ZendEngine2/tests bug41351_2.phpt bug41351_3.phpt bug41351.phpt
Modified files:
/ZendEngine2 zend_compile.c
Log:
MFH: fix #41351 (Invalid opcode with foreach ($a[] as $b))
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.38&r2=1.647.2.27.2.39&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.38 ZendEngine2/zend_compile.c:1.647.2.27.2.39
--- ZendEngine2/zend_compile.c:1.647.2.27.2.38 Fri May 4 06:18:53 2007
+++ ZendEngine2/zend_compile.c Fri May 11 09:39:36 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.647.2.27.2.38 2007/05/04 06:18:53 dmitry Exp $ */
+/* $Id: zend_compile.c,v 1.647.2.27.2.39 2007/05/11 09:39:36 tony2001 Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -3810,7 +3810,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