Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_execute.c
| From: | Zeev Suraski | Date: | Mon, 17 Feb 2003 08:20:21 +0000 |
| Subject: | Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_execute.c | ||
| References: | 1 2 | Groups: | php.zend-engine.cvs |
| Request: | Send a blank email to php-zend-engine-cvs+get-942@lists.php.net to get a copy of this message | ||
We can backport this patch to the 4 branch. The reason I haven't done it is that it's a very sensitive piece of code, and I'd rather get wide testing for it before it goes live, so 4.3.x didn't sound like a good idea :)
Zeev
At 05:16 17/02/2003, Jani Taskinen wrote:
I guess these won't be fixed in PHP 4? If so, that test should be removed from PHP_4_3 branch?tests/lang/bug21600.phpt--JaniOn Sun, 16 Feb 2003, Zeev Suraski wrote:zeev Sun Feb 16 14:18:23 2003 EDTModified files:/ZendEngine2 zend_execute.cLog: Fix complex cases of self-assignments (bugs #21600, #22231) Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.430 ZendEngine2/zend_execute.c:1.431 --- ZendEngine2/zend_execute.c:1.430 Sun Feb 16 14:10:27 2003 +++ ZendEngine2/zend_execute.c Sun Feb 16 14:18:23 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.430 2003/02/16 19:10:27 zeev Exp $ */ +/* $Id: zend_execute.c,v 1.431 2003/02/16 19:18:23 zeev Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -196,8 +196,7 @@if (variable_ptr == EG(error_zval_ptr) || value_ptr==EG(error_zval_ptr)) { variable_ptr_ptr = &EG(uninitialized_zval_ptr); -/* } else if (variable_ptr==&EG(uninitialized_zval) || variable_ptr!=value_ptr) { */ - } else if (variable_ptr_ptr != value_ptr_ptr) { + } else if (variable_ptr != value_ptr) { variable_ptr->refcount--; if (variable_ptr->refcount==0) { zendi_zval_dtor(*variable_ptr);@@ -219,9 +218,18 @@*variable_ptr_ptr = value_ptr; value_ptr->refcount++; - } else { - if (variable_ptr->refcount>1) { /* we need to break away */ + } else if (!variable_ptr->is_ref) { + if (variable_ptr_ptr == value_ptr_ptr) { SEPARATE_ZVAL(variable_ptr_ptr); + } else if (variable_ptr==EG(uninitialized_zval_ptr) + || variable_ptr->refcount>2) { + /* we need to separate */ + variable_ptr->refcount -= 2; + ALLOC_ZVAL(*variable_ptr_ptr); + **variable_ptr_ptr = *variable_ptr; + zval_copy_ctor(*variable_ptr_ptr); + *value_ptr_ptr = *variable_ptr_ptr; + (*variable_ptr_ptr)->refcount = 2; } (*variable_ptr_ptr)->is_ref = 1; }-- <- For Sale! ->