From: Dmitry Stogov Date: Thu, 27 Feb 2014 18:53:56 +0000 (+0400) Subject: Fixed ASSIGN_OBJ with IS_TMP and IS_CONST operand X-Git-Tag: POST_PHPNG_MERGE~412^2~498^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e4a97f36575c4f8562d541d4548461dd5483511;p=php Fixed ASSIGN_OBJ with IS_TMP and IS_CONST operand --- diff --git a/Zend/zend.c b/Zend/zend.c index e8a6a40ff6..dd03ea6caa 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -400,6 +400,9 @@ ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC) /* {{{ */ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC) /* {{{ */ { + if (Z_ISREF_P(expr)) { + expr = Z_REFVAL_P(expr); + } switch (Z_TYPE_P(expr)) { case IS_ARRAY: ZEND_PUTS_EX("Array\n"); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 567d2f70ba..b65e044811 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -746,6 +746,7 @@ static inline void zend_assign_to_object(zval *retval, zval *object, zval *prope { zend_free_op free_value; zval *value = get_zval_ptr(value_type, value_op, execute_data, &free_value, BP_VAR_R); + zval tmp; if (Z_TYPE_P(object) != IS_OBJECT) { if (object == &EG(error_zval)) { @@ -788,24 +789,20 @@ static inline void zend_assign_to_object(zval *retval, zval *object, zval *prope } /* separate our value if necessary */ -//??? if (value_type == IS_TMP_VAR) { -//??? ALLOC_ZVAL(value); -//??? ZVAL_COPY_VALUE(value, orig_value); -//??? Z_UNSET_ISREF_P(value); -//??? Z_SET_REFCOUNT_P(value, 0); -//??? } else if (value_type == IS_CONST) { -//??? zval *orig_value = value; -//??? -//??? ALLOC_ZVAL(value); -//??? ZVAL_COPY_VALUE(value, orig_value); -//??? Z_UNSET_ISREF_P(value); -//??? Z_SET_REFCOUNT_P(value, 0); -//??? zval_copy_ctor(value); -//??? } - - if (Z_REFCOUNTED_P(value)) { + if (value_type == IS_TMP_VAR) { + if (UNEXPECTED(Z_ISREF_P(value))) { + ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); + value = &tmp; + } + } else if (value_type == IS_CONST) { + if (UNEXPECTED(Z_ISREF_P(value))) { + value = Z_REFVAL_P(value); + } + ZVAL_DUP(&tmp, value); + } else if (Z_REFCOUNTED_P(value)) { Z_ADDREF_P(value); } + if (opcode == ZEND_ASSIGN_OBJ) { if (!Z_OBJ_HT_P(object)->write_property) { zend_error(E_WARNING, "Attempt to assign property of non-object");