From: Dmitry Stogov Date: Tue, 21 Apr 2009 08:12:07 +0000 (+0000) Subject: Fixed bug #48004 (Error handler prevents creation of default object) X-Git-Tag: php-5.3.0RC2~136 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb3c73daefc1be08fe2b8cd9f6ff33b322a69928;p=php Fixed bug #48004 (Error handler prevents creation of default object) --- diff --git a/NEWS b/NEWS index afa651a08d..7e4bfa38b8 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ PHP NEWS context. (Dmitry) - Fixed bug #48023 (spl_autoload_register didn't store closures). (Etienne) +- Fixed bug #48004 (Error handler prevents creation of default object). + (Dmitry) - Fixed bug #47880 (crashes in call_user_func_array()). (Dmitry) - Fixed bug #47856 (stristr() converts needle to lower-case). (Ilia) - Fixed bug #47851 (is_callable throws fatal error). (Dmitry) diff --git a/Zend/tests/bug48004.phpt b/Zend/tests/bug48004.phpt new file mode 100644 index 0000000000..5968876520 --- /dev/null +++ b/Zend/tests/bug48004.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #48004 (Error handler prevents creation of default object) +--FILE-- +id = 1; + print_r($data); +} + +set_error_handler("error_handler"); +test(); +?> +--EXPECT-- +stdClass Object +( + [id] => 1 +) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 5fba77a475..fb0e8fcd0b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -518,13 +518,13 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva static inline void zend_assign_to_object(znode *result, zval **object_ptr, zval *property_name, znode *value_op, const temp_variable *Ts, int opcode TSRMLS_DC) { - zval *object; + zval *object = *object_ptr; zend_free_op free_value; zval *value = get_zval_ptr(value_op, Ts, &free_value, BP_VAR_R); zval **retval = &T(result->u.var).var.ptr; - if (Z_TYPE_P(*object_ptr) != IS_OBJECT) { - if (*object_ptr == EG(error_zval_ptr)) { + if (Z_TYPE_P(object) != IS_OBJECT) { + if (object == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(result)) { *retval = EG(uninitialized_zval_ptr); PZVAL_LOCK(*retval); @@ -532,13 +532,14 @@ static inline void zend_assign_to_object(znode *result, zval **object_ptr, zval FREE_OP(free_value); return; } - if (Z_TYPE_PP(object_ptr) == IS_NULL || - (Z_TYPE_PP(object_ptr) == IS_BOOL && Z_LVAL_PP(object_ptr) == 0) || - (Z_TYPE_PP(object_ptr) == IS_STRING && Z_STRLEN_PP(object_ptr) == 0)) { - zend_error(E_STRICT, "Creating default object from empty value"); + if (Z_TYPE_P(object) == IS_NULL || + (Z_TYPE_P(object) == IS_BOOL && Z_LVAL_P(object) == 0) || + (Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0)) { SEPARATE_ZVAL_IF_NOT_REF(object_ptr); - zval_dtor(*object_ptr); - object_init(*object_ptr); + zval_dtor(object); + object = *object_ptr; + object_init(object); + zend_error(E_STRICT, "Creating default object from empty value"); } else { zend_error(E_WARNING, "Attempt to assign property of non-object"); if (!RETURN_VALUE_UNUSED(result)) { @@ -551,7 +552,6 @@ static inline void zend_assign_to_object(znode *result, zval **object_ptr, zval } /* here we are sure we are dealing with an object */ - object = *object_ptr; /* separate our value if necessary */ if (value_op->op_type == IS_TMP_VAR) {