diff options
author | David Walker <dave@mudsite.com> | 2018-02-14 22:06:34 -0700 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-14 12:50:25 +0100 |
commit | e63febb1c772e15c1da891f00e3a343090e43c67 (patch) | |
tree | 995c82b1627d266332e6cf1dfa8eca8cfce7c2a2 /Zend/zend_execute.c | |
parent | dab54624842e76350bb6f5e71a8ef0f53ed34630 (diff) | |
download | php-git-e63febb1c772e15c1da891f00e3a343090e43c67.tar.gz |
Fixed bug #75921
Ensure that the "creating default object from empty value" warning is
always thrown. Previously some cases were missing the warning, in
particular those going through FETCH_OBJ_W rather than a dedicated
opcode (like ASSIGN_OBJ).
One slightly unfortunate side-effect of this change is that something
like $a->b->c = 'd' will now generate two warnings rather than one
when $a is null (one for property b, one for property c).
Diffstat (limited to 'Zend/zend_execute.c')
-rw-r--r-- | Zend/zend_execute.c | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 2c7a4512a2..7fb7e44792 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -709,6 +709,10 @@ static zend_never_inline ZEND_COLD zval* ZEND_FASTCALL make_real_object(zval *ob || opline->opcode == ZEND_POST_INC_OBJ || opline->opcode == ZEND_POST_DEC_OBJ) { zend_error(E_WARNING, "Attempt to increment/decrement property '%s' of non-object", ZSTR_VAL(property_name)); + } else if (opline->opcode == ZEND_FETCH_OBJ_W + || opline->opcode == ZEND_FETCH_OBJ_RW + || opline->opcode == ZEND_ASSIGN_OBJ_REF) { + zend_error(E_WARNING, "Attempt to modify property '%s' of non-object", ZSTR_VAL(property_name)); } else { zend_error(E_WARNING, "Attempt to assign property '%s' of non-object", ZSTR_VAL(property_name)); } @@ -748,38 +752,6 @@ static zend_never_inline ZEND_COLD zval* ZEND_FASTCALL make_real_object(zval *ob return object; } -static zend_never_inline ZEND_COLD zval* ZEND_FASTCALL make_real_object_rw(zval *object, zval *property OPLINE_DC) -{ - zval *ref = NULL; - if (Z_ISREF_P(object)) { - ref = object; - object = Z_REFVAL_P(object); - } - - if (UNEXPECTED(Z_TYPE_P(object) > IS_FALSE && - (Z_TYPE_P(object) != IS_STRING || Z_STRLEN_P(object) != 0))) { - if (opline->op1_type != IS_VAR || EXPECTED(!Z_ISERROR_P(object))) { - zend_string *tmp_property_name; - zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name); - zend_error(E_WARNING, "Attempt to modify property '%s' of non-object", ZSTR_VAL(property_name)); - zend_tmp_string_release(tmp_property_name); - } - return NULL; - } - - if (ref) { - zend_property_info *error_prop = i_zend_check_ref_stdClass_assignable(Z_REF_P(ref)); - if (error_prop) { - zend_throw_auto_init_in_ref_error(error_prop, "stdClass"); - return NULL; - } - } - - zval_ptr_dtor_nogc(object); - object_init(object); - return object; -} - static ZEND_COLD void zend_verify_type_error_common( const zend_function *zf, const zend_arg_info *arg_info, const zend_class_entry *ce, zval *value, @@ -2736,7 +2708,7 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c return; } - container = make_real_object_rw(container, prop_ptr OPLINE_CC); + container = make_real_object(container, prop_ptr OPLINE_CC); if (UNEXPECTED(!container)) { ZVAL_ERROR(result); return; |