cvs: ZendEngine2 / zend_vm_def.h zend_vm_execute.h /tests bug40509.phpt bug40705.phpt

From: Date: Tue, 24 Jul 2007 19:24:56 +0000
Subject: cvs: ZendEngine2 / zend_vm_def.h zend_vm_execute.h /tests bug40509.phpt bug40705.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-5925@lists.php.net to get a copy of this message
dmitry Tue Jul 24 19:24:56 2007 UTC Modified files: /ZendEngine2 zend_vm_def.h zend_vm_execute.h /ZendEngine2/tests bug40509.phpt bug40705.phpt Log: Fixed bug #40705 (Iterating within function moves original array pointer) Fixed bug #40509 (key() function changed behaviour if global array is used within function) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.173&r2=1.174&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.173 ZendEngine2/zend_vm_def.h:1.174 --- ZendEngine2/zend_vm_def.h:1.173 Sat Jul 21 05:27:07 2007 +++ ZendEngine2/zend_vm_def.h Tue Jul 24 19:24:56 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.173 2007/07/21 05:27:07 pollita Exp $ */ +/* $Id: zend_vm_def.h,v 1.174 2007/07/24 19:24:56 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -3324,11 +3324,9 @@ array_ptr->refcount++; } } else { - if (OP1_TYPE == IS_VAR && - free_op1.var == NULL && + if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) && !array_ptr->is_ref && array_ptr->refcount > 1) { - /* non-separated return value from function */ zval *tmp; ALLOC_ZVAL(tmp); http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.177&r2=1.178&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.177 ZendEngine2/zend_vm_execute.h:1.178 --- ZendEngine2/zend_vm_execute.h:1.177 Sat Jul 21 05:27:07 2007 +++ ZendEngine2/zend_vm_execute.h Tue Jul 24 19:24:56 2007 @@ -1969,7 +1969,7 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); - zend_free_op free_op1; + zval *array_ptr, **array_ptr_ptr; HashTable *fe_ht; zend_object_iterator *iter = NULL; @@ -2016,11 +2016,9 @@ array_ptr->refcount++; } } else { - if (IS_CONST == IS_VAR && - free_op1.var == NULL && + if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && !array_ptr->is_ref && array_ptr->refcount > 1) { - /* non-separated return value from function */ zval *tmp; ALLOC_ZVAL(tmp); @@ -5176,11 +5174,9 @@ array_ptr->refcount++; } } else { - if (IS_TMP_VAR == IS_VAR && - free_op1.var == NULL && + if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && !array_ptr->is_ref && array_ptr->refcount > 1) { - /* non-separated return value from function */ zval *tmp; ALLOC_ZVAL(tmp); @@ -8446,11 +8442,9 @@ array_ptr->refcount++; } } else { - if (IS_VAR == IS_VAR && - free_op1.var == NULL && + if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && !array_ptr->is_ref && array_ptr->refcount > 1) { - /* non-separated return value from function */ zval *tmp; ALLOC_ZVAL(tmp); @@ -21620,7 +21614,7 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); - zend_free_op free_op1; + zval *array_ptr, **array_ptr_ptr; HashTable *fe_ht; zend_object_iterator *iter = NULL; @@ -21667,11 +21661,9 @@ array_ptr->refcount++; } } else { - if (IS_CV == IS_VAR && - free_op1.var == NULL && + if ((IS_CV == IS_VAR || IS_CV == IS_CV) && !array_ptr->is_ref && array_ptr->refcount > 1) { - /* non-separated return value from function */ zval *tmp; ALLOC_ZVAL(tmp); http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug40509.phpt?r1=1.1&r2=1.2&diff_format=u Index: ZendEngine2/tests/bug40509.phpt diff -u /dev/null ZendEngine2/tests/bug40509.phpt:1.2 --- /dev/null Tue Jul 24 19:24:56 2007 +++ ZendEngine2/tests/bug40509.phpt Tue Jul 24 19:24:56 2007 @@ -0,0 +1,26 @@ +--TEST-- +Bug #40509 key() function changed behaviour if global array is used within function +--FILE-- +<?php +function foo() +{ + global $arr; + + $c = $arr["v"]; + foreach ($c as $v) {} +} + +$arr["v"] = array("a"); + +var_dump(key($arr["v"])); +foo(); +var_dump(key($arr["v"])); +foreach ($arr["v"] as $k => $v) { + var_dump($k); +} +var_dump(key($arr["v"])); +--EXPECT-- +int(0) +int(0) +int(0) +NULL http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug40705.phpt?r1=1.1&r2=1.2&diff_format=u Index: ZendEngine2/tests/bug40705.phpt diff -u /dev/null ZendEngine2/tests/bug40705.phpt:1.2 --- /dev/null Tue Jul 24 19:24:56 2007 +++ ZendEngine2/tests/bug40705.phpt Tue Jul 24 19:24:56 2007 @@ -0,0 +1,26 @@ +--TEST-- +Bug #40705 Iterating within function moves original array pointer +--FILE-- +<?php +function doForeach($array) +{ + foreach ($array as $k => $v) { + // do stuff + } +} + +$foo = array('foo', 'bar', 'baz'); +var_dump(key($foo)); +doForeach($foo); +var_dump(key($foo)); +foreach ($foo as $k => $v) { + var_dump($k); +} +var_dump(key($foo)); +--EXPECT-- +int(0) +int(0) +int(0) +int(1) +int(2) +NULL

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