From: Nikita Popov Date: Wed, 9 Jan 2019 16:09:48 +0000 (+0100) Subject: Require that write_property value is not a reference X-Git-Tag: php-7.4.0alpha1~1253 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d6e32c6ba7cd6b608e32c5ddb078e688b7031547;p=php Require that write_property value is not a reference We explicitly dereference values before claling write_property, so no need to do duplicate work. --- diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 0f59f7378a..5f7e819531 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -766,6 +766,7 @@ ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, v zend_string *name, *tmp_name; zval *variable_ptr; uintptr_t property_offset; + ZEND_ASSERT(!Z_ISREF_P(value)); zobj = Z_OBJ_P(object); name = zval_get_tmp_string(member, &tmp_name); @@ -816,17 +817,7 @@ found: } else { ZEND_ASSERT(!IS_WRONG_PROPERTY_OFFSET(property_offset)); write_std_property: - if (Z_REFCOUNTED_P(value)) { - if (Z_ISREF_P(value)) { - /* if we assign referenced variable, we should separate it */ - value = Z_REFVAL_P(value); - if (Z_REFCOUNTED_P(value)) { - Z_ADDREF_P(value); - } - } else { - Z_ADDREF_P(value); - } - } + Z_TRY_ADDREF_P(value); if (EXPECTED(IS_VALID_PROPERTY_OFFSET(property_offset))) { ZVAL_COPY_VALUE(OBJ_PROP(zobj, property_offset), value); } else {