From e884d5d8e34a4349c2a3243832cf3379deed3cae Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 19 Mar 2014 22:43:06 +0400 Subject: [PATCH] Fixed assignment reference to itself --- Zend/zend_execute.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 12c7625744..25ac33920d 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -957,7 +957,7 @@ static inline zval* zend_assign_const_to_variable(zval *variable_ptr, zval *valu static inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value TSRMLS_DC) { zend_refcounted *garbage; - int is_ref = 0; + zval *is_ref = NULL; if (EXPECTED(!Z_REFCOUNTED_P(variable_ptr))) { if (EXPECTED(!Z_ISREF_P(value))) { @@ -967,8 +967,8 @@ static inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value TSRM } return variable_ptr; } else if (Z_ISREF_P(variable_ptr)) { + is_ref = variable_ptr; variable_ptr = Z_REFVAL_P(variable_ptr); - is_ref = 1; } if (EXPECTED(!Z_REFCOUNTED_P(variable_ptr))) { @@ -985,6 +985,8 @@ static inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value TSRM } else { ZVAL_DUP(variable_ptr, value); } + } else if (is_ref == value) { + return variable_ptr; } else { if (Z_REFCOUNT_P(value) == 1) { //??? auto dereferencing @@ -1005,7 +1007,7 @@ assign_simple: } else { ZVAL_DUP(variable_ptr, value); } - } else { + } else if (is_ref != value) { assign_ref: if (Z_REFCOUNT_P(value) == 1) { //??? auto dereferencing -- 2.40.0