diff options
author | Xinchen Hui <laruence@php.net> | 2015-04-01 13:06:38 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2015-04-01 13:06:38 +0800 |
commit | fd0baec2e9afbd6706f16c26d32ec038c192d7e5 (patch) | |
tree | 0ba31b7242cc63451c84fb9fbb1172bffa9314e9 /Zend/zend_object_handlers.c | |
parent | af812eac4c9727bdfb90cac1a35ab53d741cb7eb (diff) | |
parent | ed772e1a998ca72fc1c354fcefc05149ca7a2a56 (diff) | |
download | php-git-fd0baec2e9afbd6706f16c26d32ec038c192d7e5.tar.gz |
Merge branch 'master' of https://git.php.net/repository/php-src
Diffstat (limited to 'Zend/zend_object_handlers.c')
-rw-r--r-- | Zend/zend_object_handlers.c | 88 |
1 files changed, 57 insertions, 31 deletions
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index a5c0bf0a03..8dcd81a99a 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -170,7 +170,7 @@ ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp) /* {{{ * return ht; } - zend_error_noreturn(E_ERROR, ZEND_DEBUGINFO_FUNC_NAME "() must return an array"); + zend_error(E_ERROR, ZEND_DEBUGINFO_FUNC_NAME "() must return an array"); return NULL; /* Compilers are dumb and don't understand that noreturn means that the function does NOT need a return value... */ } @@ -298,9 +298,9 @@ static zend_always_inline uint32_t zend_get_property_offset(zend_class_entry *ce if (UNEXPECTED(member->val[0] == '\0')) { if (!silent) { if (member->len == 0) { - zend_error_noreturn(E_ERROR, "Cannot access empty property"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access empty property"); } else { - zend_error_noreturn(E_ERROR, "Cannot access property started with '\\0'"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access property started with '\\0'"); } } return ZEND_WRONG_PROPERTY_OFFSET; @@ -354,7 +354,7 @@ exit_dynamic: } else if (UNEXPECTED(property_info == ZEND_WRONG_PROPERTY_INFO)) { /* Information was available, but we were denied access. Error out. */ if (!silent) { - zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(flags), ce->name->val, member->val); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(flags), ce->name->val, member->val); } return ZEND_WRONG_PROPERTY_OFFSET; } @@ -376,9 +376,9 @@ ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_s if (UNEXPECTED(member->val[0] == '\0')) { if (!silent) { if (member->len == 0) { - zend_error_noreturn(E_ERROR, "Cannot access empty property"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access empty property"); } else { - zend_error_noreturn(E_ERROR, "Cannot access property started with '\\0'"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access property started with '\\0'"); } } return ZEND_WRONG_PROPERTY_INFO; @@ -425,7 +425,7 @@ exit_dynamic: } else if (UNEXPECTED(property_info == ZEND_WRONG_PROPERTY_INFO)) { /* Information was available, but we were denied access. Error out. */ if (!silent) { - zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(flags), ce->name->val, member->val); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(flags), ce->name->val, member->val); } return ZEND_WRONG_PROPERTY_INFO; } @@ -538,6 +538,9 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_ retval = zend_hash_find(zobj->properties, Z_STR_P(member)); if (EXPECTED(retval)) goto exit; } + } else if (UNEXPECTED(EG(exception))) { + retval = &EG(uninitialized_zval); + goto exit; } /* magic get */ @@ -569,9 +572,13 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_ } else { if (Z_STRVAL_P(member)[0] == '\0') { if (Z_STRLEN_P(member) == 0) { - zend_error(E_ERROR, "Cannot access empty property"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access empty property"); + retval = &EG(uninitialized_zval); + goto exit; } else { - zend_error(E_ERROR, "Cannot access property started with '\\0'"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access property started with '\\0'"); + retval = &EG(uninitialized_zval); + goto exit; } } } @@ -622,6 +629,8 @@ found: goto exit; } } + } else if (UNEXPECTED(EG(exception))) { + goto exit; } /* magic set */ @@ -643,9 +652,11 @@ found: } else { if (Z_STRVAL_P(member)[0] == '\0') { if (Z_STRLEN_P(member) == 0) { - zend_error(E_ERROR, "Cannot access empty property"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access empty property"); + goto exit; } else { - zend_error(E_ERROR, "Cannot access property started with '\\0'"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access property started with '\\0'"); + goto exit; } } } @@ -698,13 +709,13 @@ zval *zend_std_read_dimension(zval *object, zval *offset, int type, zval *rv) /* if (UNEXPECTED(Z_TYPE_P(rv) == IS_UNDEF)) { if (UNEXPECTED(!EG(exception))) { - zend_error_noreturn(E_ERROR, "Undefined offset for object of type %s used as array", ce->name->val); + zend_error(E_EXCEPTION | E_ERROR, "Undefined offset for object of type %s used as array", ce->name->val); } return NULL; } return rv; } else { - zend_error_noreturn(E_ERROR, "Cannot use object of type %s as array", ce->name->val); + zend_error(E_EXCEPTION | E_ERROR, "Cannot use object of type %s as array", ce->name->val); return NULL; } } @@ -725,7 +736,7 @@ static void zend_std_write_dimension(zval *object, zval *offset, zval *value) /* zend_call_method_with_2_params(object, ce, NULL, "offsetset", NULL, offset, value); zval_ptr_dtor(offset); } else { - zend_error_noreturn(E_ERROR, "Cannot use object of type %s as array", ce->name->val); + zend_error(E_EXCEPTION | E_ERROR, "Cannot use object of type %s as array", ce->name->val); } } /* }}} */ @@ -754,7 +765,7 @@ static int zend_std_has_dimension(zval *object, zval *offset, int check_empty) / } zval_ptr_dtor(offset); } else { - zend_error_noreturn(E_ERROR, "Cannot use object of type %s as array", ce->name->val); + zend_error(E_EXCEPTION | E_ERROR, "Cannot use object of type %s as array", ce->name->val); return 0; } return result; @@ -854,6 +865,8 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo EXPECTED(zend_hash_del(zobj->properties, Z_STR_P(member)) != FAILURE)) { goto exit; } + } else if (UNEXPECTED(EG(exception))) { + goto exit; } /* magic unset */ @@ -871,9 +884,11 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo } else { if (Z_STRVAL_P(member)[0] == '\0') { if (Z_STRLEN_P(member) == 0) { - zend_error(E_ERROR, "Cannot access empty property"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access empty property"); + goto exit; } else { - zend_error(E_ERROR, "Cannot access property started with '\\0'"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access property started with '\\0'"); + goto exit; } } } @@ -895,7 +910,7 @@ static void zend_std_unset_dimension(zval *object, zval *offset) /* {{{ */ zend_call_method_with_1_params(object, ce, NULL, "offsetunset", NULL, offset); zval_ptr_dtor(offset); } else { - zend_error_noreturn(E_ERROR, "Cannot use object of type %s as array", ce->name->val); + zend_error(E_EXCEPTION | E_ERROR, "Cannot use object of type %s as array", ce->name->val); } } /* }}} */ @@ -911,7 +926,7 @@ ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ if (UNEXPECTED(zend_copy_parameters_array(ZEND_NUM_ARGS(), &method_args) == FAILURE)) { zval_dtor(&method_args); - zend_error_noreturn(E_ERROR, "Cannot get arguments for __call"); + zend_error(E_EXCEPTION | E_ERROR, "Cannot get arguments for __call"); RETURN_FALSE; } @@ -1085,7 +1100,8 @@ static union _zend_function *zend_std_get_method(zend_object **obj_ptr, zend_str if (zobj->ce->__call) { fbc = zend_get_user_call_function(zobj->ce, method_name); } else { - zend_error_noreturn(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name->val, EG(scope) ? EG(scope)->name->val : ""); + zend_error(E_EXCEPTION | E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name->val, EG(scope) ? EG(scope)->name->val : ""); + fbc = NULL; } } } else { @@ -1111,7 +1127,8 @@ static union _zend_function *zend_std_get_method(zend_object **obj_ptr, zend_str if (zobj->ce->__call) { fbc = zend_get_user_call_function(zobj->ce, method_name); } else { - zend_error_noreturn(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name->val, EG(scope) ? EG(scope)->name->val : ""); + zend_error(E_EXCEPTION | E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name->val, EG(scope) ? EG(scope)->name->val : ""); + fbc = NULL; } } } @@ -1135,7 +1152,7 @@ ZEND_API void zend_std_callstatic_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ if (UNEXPECTED(zend_copy_parameters_array(ZEND_NUM_ARGS(), &method_args) == FAILURE)) { zval_dtor(&method_args); - zend_error_noreturn(E_ERROR, "Cannot get arguments for " ZEND_CALLSTATIC_FUNC_NAME); + zend_error(E_EXCEPTION | E_ERROR, "Cannot get arguments for " ZEND_CALLSTATIC_FUNC_NAME); RETURN_FALSE; } @@ -1252,7 +1269,8 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st if (ce->__callstatic) { fbc = zend_get_user_callstatic_function(ce, function_name); } else { - zend_error_noreturn(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), function_name->val, EG(scope) ? EG(scope)->name->val : ""); + zend_error(E_EXCEPTION | E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), function_name->val, EG(scope) ? EG(scope)->name->val : ""); + fbc = NULL; } } } else if ((fbc->common.fn_flags & ZEND_ACC_PROTECTED)) { @@ -1262,7 +1280,8 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st if (ce->__callstatic) { fbc = zend_get_user_callstatic_function(ce, function_name); } else { - zend_error_noreturn(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), function_name->val, EG(scope) ? EG(scope)->name->val : ""); + zend_error(E_EXCEPTION | E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), function_name->val, EG(scope) ? EG(scope)->name->val : ""); + fbc = NULL; } } } @@ -1286,7 +1305,7 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p if (UNEXPECTED(!zend_verify_property_access(property_info, ce))) { if (!silent) { - zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name->val, property_name->val); + zend_error(E_EXCEPTION | E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name->val, property_name->val); } return NULL; } @@ -1302,7 +1321,7 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) { undeclared_property: if (!silent) { - zend_error_noreturn(E_ERROR, "Access to undeclared static property: %s::$%s", ce->name->val, property_name->val); + zend_error(E_EXCEPTION | E_ERROR, "Access to undeclared static property: %s::$%s", ce->name->val, property_name->val); } ret = NULL; } @@ -1313,7 +1332,7 @@ undeclared_property: ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name) /* {{{ */ { - zend_error_noreturn(E_ERROR, "Attempt to unset static property %s::$%s", ce->name->val, property_name->val); + zend_error(E_EXCEPTION | E_ERROR, "Attempt to unset static property %s::$%s", ce->name->val, property_name->val); return 0; } /* }}} */ @@ -1330,9 +1349,11 @@ ZEND_API union _zend_function *zend_std_get_constructor(zend_object *zobj) /* {{ */ if (UNEXPECTED(constructor->common.scope != EG(scope))) { if (EG(scope)) { - zend_error_noreturn(E_ERROR, "Call to private %s::%s() from context '%s'", constructor->common.scope->name->val, constructor->common.function_name->val, EG(scope)->name->val); + zend_error(E_EXCEPTION | E_ERROR, "Call to private %s::%s() from context '%s'", constructor->common.scope->name->val, constructor->common.function_name->val, EG(scope)->name->val); + constructor = NULL; } else { - zend_error_noreturn(E_ERROR, "Call to private %s::%s() from invalid context", constructor->common.scope->name->val, constructor->common.function_name->val); + zend_error(E_EXCEPTION | E_ERROR, "Call to private %s::%s() from invalid context", constructor->common.scope->name->val, constructor->common.function_name->val); + constructor = NULL; } } } else if ((constructor->common.fn_flags & ZEND_ACC_PROTECTED)) { @@ -1342,9 +1363,11 @@ ZEND_API union _zend_function *zend_std_get_constructor(zend_object *zobj) /* {{ */ if (UNEXPECTED(!zend_check_protected(zend_get_function_root_class(constructor), EG(scope)))) { if (EG(scope)) { - zend_error_noreturn(E_ERROR, "Call to protected %s::%s() from context '%s'", constructor->common.scope->name->val, constructor->common.function_name->val, EG(scope)->name->val); + zend_error(E_EXCEPTION | E_ERROR, "Call to protected %s::%s() from context '%s'", constructor->common.scope->name->val, constructor->common.function_name->val, EG(scope)->name->val); + constructor = NULL; } else { - zend_error_noreturn(E_ERROR, "Call to protected %s::%s() from invalid context", constructor->common.scope->name->val, constructor->common.function_name->val); + zend_error(E_EXCEPTION | E_ERROR, "Call to protected %s::%s() from invalid context", constructor->common.scope->name->val, constructor->common.function_name->val); + constructor = NULL; } } } @@ -1456,6 +1479,9 @@ found: } goto exit; } + } else if (UNEXPECTED(EG(exception))) { + result = 0; + goto exit; } result = 0; |