From 3ae3341533b68cccaccfc0d78456b72d004dfc80 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 4 Dec 2015 11:10:07 +0800 Subject: Fixed bug #71018 (ReflectionProperty::setValue() behavior changed) --- ext/reflection/php_reflection.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'ext/reflection/php_reflection.c') diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 72df8b5901..80001e4997 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -5448,31 +5448,16 @@ ZEND_METHOD(reflection_property, setValue) } variable_ptr = &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]; if (variable_ptr != value) { - if (Z_ISREF_P(variable_ptr)) { - zval garbage; + zval garbage; - ZVAL_COPY_VALUE(&garbage, variable_ptr); /* old value should be destroyed */ + ZVAL_DEREF(variable_ptr); + ZVAL_DEREF(value); - /* To check: can't *variable_ptr be some system variable like error_zval here? */ - ZVAL_COPY_VALUE(variable_ptr, value); - if (Z_REFCOUNTED_P(value) && Z_REFCOUNT_P(value) > 0) { - zval_copy_ctor(variable_ptr); - } - zval_dtor(&garbage); - } else { - zval garbage; + ZVAL_COPY_VALUE(&garbage, variable_ptr); - ZVAL_COPY_VALUE(&garbage, variable_ptr); - /* if we assign referenced variable, we should separate it */ - if (Z_REFCOUNTED_P(value)) { - Z_ADDREF_P(value); - } - if (Z_ISREF_P(value)) { - SEPARATE_ZVAL(value); - } - ZVAL_COPY_VALUE(variable_ptr, value); - zval_ptr_dtor(&garbage); - } + ZVAL_COPY(variable_ptr, value); + + zval_ptr_dtor(&garbage); } } else { const char *class_name, *prop_name; -- cgit v1.2.1