From: Dmitry Stogov Date: Thu, 1 Sep 2005 10:54:38 +0000 (+0000) Subject: Fixed bug #34310 (foreach($arr as $c->d => $x) crashes) X-Git-Tag: php-5.1.0RC2_PRE~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=40f971b5b6f44b1f7a17acd16e4ce546d4b3ecae;p=php Fixed bug #34310 (foreach($arr as $c->d => $x) crashes) --- diff --git a/NEWS b/NEWS index 66e0166e03..8617be6bfc 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ PHP NEWS - Fixed "make test" to work for phpized extensions. (Hartmut, Jani) - Fixed failing queries (FALSE returned) with mysqli_query() on 64 bit systems. (Andrey) +- Fixed bug #34310 (foreach($arr as $c->d => $x) crashes). (Dmitry) - Fixed bug #34306 (wddx_serialize_value() crashes with long array keys). (Jani) - Fixed bug #34302 (date('W') do not return leading zeros for week 1 to 9). (Derick) diff --git a/Zend/tests/bug34310.phpt b/Zend/tests/bug34310.phpt index 2f7c477149..1d2bb03ad3 100644 --- a/Zend/tests/bug34310.phpt +++ b/Zend/tests/bug34310.phpt @@ -5,7 +5,7 @@ Bug #34310 (foreach($arr as $c->d => $x) crashes) class C { - var $d; + public $d; } $c = new C(); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ec1df4b844..c1a4f586dd 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -543,14 +543,20 @@ void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC) if (last_op_number > 0) { zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1]; - if (last_op->opcode == ZEND_FETCH_OBJ_W) { + 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; 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) { + } 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);