cvs: ZendEngine2(PHP_5_1) / zend_vm_def.h zend_vm_execute.h /tests bug37046.phpt php-src NEWS
| From: | Dmitry Stogov | Date: | Wed, 12 Apr 2006 11:37:51 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_1) / zend_vm_def.h zend_vm_execute.h /tests bug37046.phpt php-src NEWS | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4806@lists.php.net to get a copy of this message | ||
dmitry Wed Apr 12 11:37:51 2006 UTC
Added files: (Branch: PHP_5_1)
/ZendEngine2/tests bug37046.phpt
Modified files:
/php-src NEWS
/ZendEngine2 zend_vm_def.h zend_vm_execute.h
Log:
Fixed bug #37046 (foreach breaks static scope)
http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.505&r2=1.2027.2.506&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.505 php-src/NEWS:1.2027.2.506
--- php-src/NEWS:1.2027.2.505 Wed Apr 12 09:51:54 2006
+++ php-src/NEWS Wed Apr 12 11:37:49 2006
@@ -1,8 +1,9 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? Apr 2006, PHP 5.1.3
+- Fixed bug #37046 (foreach breaks static scope). (Dmitry)
- Fixed bug #37002 (Have to quote literals in INI when concatenating with
- vars). (Dmitry)
+ vars). (Dmitry)
06 Apr 2006, PHP 5.1.3RC3
- Eliminated run-time constant fetching for TRUE, FALSE and NULL. (Dmitry)
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_vm_def.h?r1=1.59.2.28&r2=1.59.2.29&diff_format=u
Index: ZendEngine2/zend_vm_def.h
diff -u ZendEngine2/zend_vm_def.h:1.59.2.28 ZendEngine2/zend_vm_def.h:1.59.2.29
--- ZendEngine2/zend_vm_def.h:1.59.2.28 Mon Apr 10 23:16:29 2006
+++ ZendEngine2/zend_vm_def.h Wed Apr 12 11:37:50 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_vm_def.h,v 1.59.2.28 2006/04/10 23:16:29 helly Exp $ */
+/* $Id: zend_vm_def.h,v 1.59.2.29 2006/04/12 11:37:50 dmitry Exp $ */
/* If you change this file, please regenerate the zend_vm_execute.h and
* zend_vm_opcodes.h files by running:
@@ -3017,7 +3017,20 @@
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
ce = Z_OBJCE_P(array_ptr);
} else {
- array_ptr->refcount++;
+ if (OP1_TYPE == IS_VAR &&
+ free_op1.var == NULL &&
+ !array_ptr->is_ref &&
+ array_ptr->refcount > 1) {
+ /* non-separated return value from function */
+ zval *tmp;
+
+ ALLOC_ZVAL(tmp);
+ INIT_PZVAL_COPY(tmp, array_ptr);
+ zval_copy_ctor(tmp);
+ array_ptr = tmp;
+ } else {
+ array_ptr->refcount++;
+ }
}
}
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_vm_execute.h?r1=1.62.2.29&r2=1.62.2.30&diff_format=u
Index: ZendEngine2/zend_vm_execute.h
diff -u ZendEngine2/zend_vm_execute.h:1.62.2.29 ZendEngine2/zend_vm_execute.h:1.62.2.30
--- ZendEngine2/zend_vm_execute.h:1.62.2.29 Mon Apr 10 23:16:29 2006
+++ ZendEngine2/zend_vm_execute.h Wed Apr 12 11:37:50 2006
@@ -2059,7 +2059,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;
@@ -2100,7 +2100,20 @@
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
ce = Z_OBJCE_P(array_ptr);
} else {
- array_ptr->refcount++;
+ if (IS_CONST == IS_VAR &&
+ free_op1.var == NULL &&
+ !array_ptr->is_ref &&
+ array_ptr->refcount > 1) {
+ /* non-separated return value from function */
+ zval *tmp;
+
+ ALLOC_ZVAL(tmp);
+ INIT_PZVAL_COPY(tmp, array_ptr);
+ zval_copy_ctor(tmp);
+ array_ptr = tmp;
+ } else {
+ array_ptr->refcount++;
+ }
}
}
@@ -4518,7 +4531,20 @@
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
ce = Z_OBJCE_P(array_ptr);
} else {
- array_ptr->refcount++;
+ if (IS_TMP_VAR == IS_VAR &&
+ free_op1.var == NULL &&
+ !array_ptr->is_ref &&
+ array_ptr->refcount > 1) {
+ /* non-separated return value from function */
+ zval *tmp;
+
+ ALLOC_ZVAL(tmp);
+ INIT_PZVAL_COPY(tmp, array_ptr);
+ zval_copy_ctor(tmp);
+ array_ptr = tmp;
+ } else {
+ array_ptr->refcount++;
+ }
}
}
@@ -7518,7 +7544,20 @@
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
ce = Z_OBJCE_P(array_ptr);
} else {
- array_ptr->refcount++;
+ if (IS_VAR == IS_VAR &&
+ free_op1.var == NULL &&
+ !array_ptr->is_ref &&
+ array_ptr->refcount > 1) {
+ /* non-separated return value from function */
+ zval *tmp;
+
+ ALLOC_ZVAL(tmp);
+ INIT_PZVAL_COPY(tmp, array_ptr);
+ zval_copy_ctor(tmp);
+ array_ptr = tmp;
+ } else {
+ array_ptr->refcount++;
+ }
}
}
@@ -19576,7 +19615,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;
@@ -19617,7 +19656,20 @@
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
ce = Z_OBJCE_P(array_ptr);
} else {
- array_ptr->refcount++;
+ if (IS_CV == IS_VAR &&
+ free_op1.var == NULL &&
+ !array_ptr->is_ref &&
+ array_ptr->refcount > 1) {
+ /* non-separated return value from function */
+ zval *tmp;
+
+ ALLOC_ZVAL(tmp);
+ INIT_PZVAL_COPY(tmp, array_ptr);
+ zval_copy_ctor(tmp);
+ array_ptr = tmp;
+ } else {
+ array_ptr->refcount++;
+ }
}
}
http://cvs.php.net/viewcvs.cgi/ZendEngine2/tests/bug37046.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug37046.phpt
+++ ZendEngine2/tests/bug37046.phpt