Skip to content

Commit

Permalink
Fix order of dynamic/readonly property checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kocsismate committed Aug 29, 2022
1 parent f1a6837 commit 817adf5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions ext/spl/spl_fixedarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ PHP_METHOD(SplFixedArray, __unserialize)
if (intern->array.size == 0) {
size = zend_hash_num_elements(data);
spl_fixedarray_init_non_empty_struct(&intern->array, size);
if (!size) {
return;
}
array_init(&members_zv);

intern->array.size = 0;
Expand Down
24 changes: 12 additions & 12 deletions ext/standard/var_unserializer.re
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,18 @@ declared_property:
int ret = is_property_visibility_changed(obj->ce, &key);

if (EXPECTED(!ret)) {
if (UNEXPECTED(obj->ce->ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES)) {
zend_throw_error(NULL, "Cannot create dynamic property %s::$%s",
ZSTR_VAL(obj->ce->name), zend_get_unmangled_property_name(Z_STR_P(&key)));
goto failure;
} else if (!(obj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) {
zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated",
ZSTR_VAL(obj->ce->name), zend_get_unmangled_property_name(Z_STR_P(&key)));
if (EG(exception)) {
goto failure;
}
}

data = zend_hash_add_new(ht, Z_STR(key), &EG(uninitialized_zval));
} else if (ret < 0) {
goto failure;
Expand All @@ -654,18 +666,6 @@ second_try:
ZVAL_NULL(data);
}
}

if (UNEXPECTED(obj->ce->ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES)) {
zend_throw_error(NULL, "Cannot create dynamic property %s::$%s",
ZSTR_VAL(obj->ce->name), zend_get_unmangled_property_name(Z_STR_P(&key)));
goto failure;
} else if (!(obj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) {
zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated",
ZSTR_VAL(obj->ce->name), zend_get_unmangled_property_name(Z_STR_P(&key)));
if (EG(exception)) {
goto failure;
}
}
}
zval_ptr_dtor_str(&key);
} else if (Z_TYPE(key) == IS_LONG) {
Expand Down

0 comments on commit 817adf5

Please sign in to comment.