]> granicus.if.org Git - php/commitdiff
Fixed assignment reference to itself
authorDmitry Stogov <dmitry@zend.com>
Wed, 19 Mar 2014 18:43:06 +0000 (22:43 +0400)
committerDmitry Stogov <dmitry@zend.com>
Wed, 19 Mar 2014 18:43:06 +0000 (22:43 +0400)
Zend/zend_execute.c

index 12c7625744d45e82b0824d35df9885456aebd94c..25ac33920d882d2f4890267534f549ef4ec02dbe 100644 (file)
@@ -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