summaryrefslogtreecommitdiff
path: root/Zend/zend_execute.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2008-01-11 08:42:06 +0000
committerDmitry Stogov <dmitry@php.net>2008-01-11 08:42:06 +0000
commitab5bddd976fb511a6c78723d0f12a09059213c74 (patch)
tree45031638fe6c0c0a67c37494e8c942da8d4fd34c /Zend/zend_execute.c
parentfa1e1d249bf4ea3ad1247992b7a7b7d9844e978f (diff)
downloadphp-git-ab5bddd976fb511a6c78723d0f12a09059213c74.tar.gz
Fixed bug #39346 (Unsetting a static variable inside a destructor causes segfault later on)
Diffstat (limited to 'Zend/zend_execute.c')
-rw-r--r--Zend/zend_execute.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 865a4003f3..1f417fab0e 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -691,6 +691,7 @@ static inline void zend_assign_to_string_offset(temp_variable *T, zval *value, i
static inline zval* zend_assign_to_variable(zval **variable_ptr_ptr, zval *value, int is_tmp_var TSRMLS_DC)
{
zval *variable_ptr = *variable_ptr_ptr;
+ zval garbage;
if (variable_ptr == EG(error_zval_ptr)) {
if (is_tmp_var) {
@@ -716,7 +717,6 @@ static inline zval* zend_assign_to_variable(zval **variable_ptr_ptr, zval *value
} else if (PZVAL_IS_REF(variable_ptr)) {
if (variable_ptr != value) {
zend_uint refcount = Z_REFCOUNT_P(variable_ptr);
- zval garbage;
if (!is_tmp_var) {
Z_ADDREF_P(value);
@@ -756,7 +756,6 @@ static inline zval* zend_assign_to_variable(zval **variable_ptr_ptr, zval *value
} else if (PZVAL_IS_REF(variable_ptr)) {
if (variable_ptr!=value) {
zend_uint refcount = Z_REFCOUNT_P(variable_ptr);
- zval garbage;
if (!is_tmp_var) {
Z_ADDREF_P(value);
@@ -778,23 +777,25 @@ static inline zval* zend_assign_to_variable(zval **variable_ptr_ptr, zval *value
if (variable_ptr==value) {
Z_ADDREF_P(variable_ptr);
} else if (PZVAL_IS_REF(value)) {
- zval tmp;
-
- tmp = *value;
- zval_copy_ctor(&tmp);
- Z_SET_REFCOUNT(tmp, 1);
- zendi_zval_dtor(*variable_ptr);
- *variable_ptr = tmp;
+ garbage = *variable_ptr;
+ *variable_ptr = *value;
+ INIT_PZVAL(variable_ptr);
+ zval_copy_ctor(variable_ptr);
+ zendi_zval_dtor(garbage);
+ return variable_ptr;
} else {
Z_ADDREF_P(value);
+ *variable_ptr_ptr = value;
zendi_zval_dtor(*variable_ptr);
safe_free_zval_ptr(variable_ptr);
- *variable_ptr_ptr = value;
+ return value;
}
} else {
- zendi_zval_dtor(*variable_ptr);
- Z_SET_REFCOUNT_P(value, 1);
+ garbage = *variable_ptr;
*variable_ptr = *value;
+ INIT_PZVAL(variable_ptr);
+ zendi_zval_dtor(garbage);
+ return variable_ptr;
}
} else { /* we need to split */
if (!is_tmp_var) {