cvs: ZendEngine2(PHP_5_1) / zend_compile.c /tests bug34467.phpt php-src NEWS
| From: | Dmitry Stogov | Date: | Mon, 10 Oct 2005 09:50:06 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_1) / zend_compile.c /tests bug34467.phpt php-src NEWS | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4221@lists.php.net to get a copy of this message | ||
dmitry Mon Oct 10 05:50:06 2005 EDT
Added files: (Branch: PHP_5_1)
/ZendEngine2/tests bug34467.phpt
Modified files:
/php-src NEWS
/ZendEngine2 zend_compile.c
Log:
Fixed bug #34467 (foreach + __get + __set incosistency)
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2027.2.107&r2=1.2027.2.108&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.107 php-src/NEWS:1.2027.2.108
--- php-src/NEWS:1.2027.2.107 Sun Oct 9 16:40:46 2005
+++ php-src/NEWS Mon Oct 10 05:49:57 2005
@@ -70,6 +70,7 @@
- Fixed bug #34505 (Possible memory corruption when unmangling properties
with empty names). (Tony)
- Fixed bug #34478 (Incorrect parsing of url's fragment (#...)). (Dmitry)
+- Fixed bug #34467 (foreach + __get + __set incosistency). (Dmitry)
- Fixed bug #34456 (Possible crash inside pspell extension). (Nuno)
- Fixed bug #34453 (parsing http://www.w3.org/2001/xml.xsd exception). (Dmitry)
- Fixed bug #34450 (Segfault when calling mysqli_close() in destructor). (Tony)
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.647.2.7&r2=1.647.2.8&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.647.2.7 ZendEngine2/zend_compile.c:1.647.2.8
--- ZendEngine2/zend_compile.c:1.647.2.7 Mon Oct 3 04:21:51 2005
+++ ZendEngine2/zend_compile.c Mon Oct 10 05:50:02 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.647.2.7 2005/10/03 08:21:51 dmitry Exp $ */
+/* $Id: zend_compile.c,v 1.647.2.8 2005/10/10 09:50:02 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -537,40 +537,53 @@
void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC)
{
- int last_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
- if (last_op_number > 0) {
- zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1];
+ if (variable->op_type == IS_VAR) {
+ int last_op_number = get_next_op_number(CG(active_op_array));
+ int n = 0;
- if (variable->op_type == IS_VAR &&
- last_op->opcode == ZEND_FETCH_OBJ_W &&
- last_op->result.op_type == IS_VAR &&
- last_op->result.u.var == variable->u.var) {
- last_op->opcode = ZEND_ASSIGN_OBJ;
+ while (last_op_number - n > 0) {
+ zend_op *last_op;
+
+ last_op = &CG(active_op_array)->opcodes[last_op_number-n-1];
- zend_do_op_data(opline, value TSRMLS_CC);
- SET_UNUSED(opline->result);
- *result = last_op->result;
- return;
- } else if (variable->op_type == IS_VAR &&
- last_op->opcode == ZEND_FETCH_DIM_W &&
- last_op->result.op_type == IS_VAR &&
- last_op->result.u.var == variable->u.var) {
- last_op->opcode = ZEND_ASSIGN_DIM;
-
- zend_do_op_data(opline, value TSRMLS_CC);
- opline->op2.u.var = get_temporary_variable(CG(active_op_array));
- opline->op2.u.EA.type = 0;
- opline->op2.op_type = IS_VAR;
- SET_UNUSED(opline->result);
- *result = last_op->result;
- return;
- } else {
- if (variable->op_type == IS_VAR &&
- opline_is_fetch_this(last_op TSRMLS_CC)) {
- zend_error(E_COMPILE_ERROR, "Cannot re-assign $this");
+ if (last_op->result.op_type == IS_VAR &&
+ last_op->result.u.var == variable->u.var) {
+ if (last_op->opcode == ZEND_FETCH_OBJ_W) {
+ if (n > 0) {
+ *opline = *last_op;
+ MAKE_NOP(last_op);
+ last_op = opline;
+ opline = get_next_op(CG(active_op_array) TSRMLS_CC);
+ }
+ last_op->opcode = ZEND_ASSIGN_OBJ;
+ zend_do_op_data(opline, value TSRMLS_CC);
+ SET_UNUSED(opline->result);
+ *result = last_op->result;
+ return;
+ } else if (last_op->opcode == ZEND_FETCH_DIM_W) {
+ if (n > 0) {
+ *opline = *last_op;
+ MAKE_NOP(last_op);
+ last_op = opline;
+ opline = get_next_op(CG(active_op_array) TSRMLS_CC);
+ }
+ last_op->opcode = ZEND_ASSIGN_DIM;
+ zend_do_op_data(opline, value TSRMLS_CC);
+ opline->op2.u.var = get_temporary_variable(CG(active_op_array));
+ opline->op2.u.EA.type = 0;
+ opline->op2.op_type = IS_VAR;
+ SET_UNUSED(opline->result);
+ *result = last_op->result;
+ return;
+ } else if (opline_is_fetch_this(last_op TSRMLS_CC)) {
+ zend_error(E_COMPILE_ERROR, "Cannot re-assign $this");
+ } else {
+ break;
+ }
}
+ n++;
}
}
http://cvs.php.net/co.php/ZendEngine2/tests/bug34467.phpt?r=1.1&p=1
Index: ZendEngine2/tests/bug34467.phpt
+++ ZendEngine2/tests/bug34467.phpt