Skip to content

Commit 817adf5

Browse files
committed
Fix order of dynamic/readonly property checks
1 parent f1a6837 commit 817adf5

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

ext/spl/spl_fixedarray.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ PHP_METHOD(SplFixedArray, __unserialize)
629629
if (intern->array.size == 0) {
630630
size = zend_hash_num_elements(data);
631631
spl_fixedarray_init_non_empty_struct(&intern->array, size);
632+
if (!size) {
633+
return;
634+
}
632635
array_init(&members_zv);
633636

634637
intern->array.size = 0;

ext/standard/var_unserializer.re

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,18 @@ declared_property:
641641
int ret = is_property_visibility_changed(obj->ce, &key);
642642

643643
if (EXPECTED(!ret)) {
644+
if (UNEXPECTED(obj->ce->ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES)) {
645+
zend_throw_error(NULL, "Cannot create dynamic property %s::$%s",
646+
ZSTR_VAL(obj->ce->name), zend_get_unmangled_property_name(Z_STR_P(&key)));
647+
goto failure;
648+
} else if (!(obj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) {
649+
zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated",
650+
ZSTR_VAL(obj->ce->name), zend_get_unmangled_property_name(Z_STR_P(&key)));
651+
if (EG(exception)) {
652+
goto failure;
653+
}
654+
}
655+
644656
data = zend_hash_add_new(ht, Z_STR(key), &EG(uninitialized_zval));
645657
} else if (ret < 0) {
646658
goto failure;
@@ -654,18 +666,6 @@ second_try:
654666
ZVAL_NULL(data);
655667
}
656668
}
657-
658-
if (UNEXPECTED(obj->ce->ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES)) {
659-
zend_throw_error(NULL, "Cannot create dynamic property %s::$%s",
660-
ZSTR_VAL(obj->ce->name), zend_get_unmangled_property_name(Z_STR_P(&key)));
661-
goto failure;
662-
} else if (!(obj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) {
663-
zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated",
664-
ZSTR_VAL(obj->ce->name), zend_get_unmangled_property_name(Z_STR_P(&key)));
665-
if (EG(exception)) {
666-
goto failure;
667-
}
668-
}
669669
}
670670
zval_ptr_dtor_str(&key);
671671
} else if (Z_TYPE(key) == IS_LONG) {

0 commit comments

Comments
 (0)