diff options
author | Dmitry Stogov <dmitry@zend.com> | 2016-09-29 10:57:09 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2016-09-29 10:57:09 +0300 |
commit | 8863ca76e6121b1b30c4bb1bb8af23beab1d628d (patch) | |
tree | 940b598cc07d92b3b732c39c77c657502539a478 /Zend/zend_execute.c | |
parent | 36d5bed262e4ea29c767da7a276ab965d2d5c5e2 (diff) | |
parent | e7f4355d9b6777bc9fc44ac3a109c52f5d304889 (diff) | |
download | php-git-8863ca76e6121b1b30c4bb1bb8af23beab1d628d.tar.gz |
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
Better fix for bug #72854 (avoid extra copy and creating reference to stack variable)
Diffstat (limited to 'Zend/zend_execute.c')
-rw-r--r-- | Zend/zend_execute.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index c748a77711..b1f4e27bc7 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -567,7 +567,6 @@ static inline zval *_get_obj_zval_ptr_ptr(int op_type, znode_op node, zend_execu static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr) { zend_reference *ref; - zval garbage; if (EXPECTED(!Z_ISREF_P(value_ptr))) { ZVAL_NEW_REF(value_ptr, value_ptr); @@ -577,9 +576,18 @@ static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *v ref = Z_REF_P(value_ptr); GC_REFCOUNT(ref)++; - ZVAL_COPY_VALUE(&garbage, variable_ptr); + if (Z_REFCOUNTED_P(variable_ptr)) { + zend_refcounted *garbage = Z_COUNTED_P(variable_ptr); + + if (--GC_REFCOUNT(garbage) == 0) { + ZVAL_REF(variable_ptr, ref); + zval_dtor_func_for_ptr(garbage); + return; + } else { + GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr); + } + } ZVAL_REF(variable_ptr, ref); - zval_ptr_dtor(&garbage); } /* this should modify object only if it's empty */ |