Skip to content

Commit ee5ffbb

Browse files
committed
Make sure fetch_property_type_info is only used with valid offset
It's not relevant in any other case and might be wrong wrt cache state I think.
1 parent fc1e7a2 commit ee5ffbb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Zend/zend_object_handlers.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,8 @@ ZEND_API zval *zend_std_read_property(zval *object, zval *member, int type, void
742742
}
743743

744744
if (UNEXPECTED(ZEND_CLASS_HAS_TYPE_HINTS(zobj->ce) &&
745-
(prop_info = zend_object_fetch_property_type_info(Z_OBJCE_P(object), name, IS_VALID_PROPERTY_OFFSET(property_offset) ? cache_slot : NULL)))) {
745+
IS_VALID_PROPERTY_OFFSET(property_offset) &&
746+
(prop_info = zend_object_fetch_property_type_info(Z_OBJCE_P(object), name, cache_slot)))) {
746747
zend_verify_prop_assignable_by_ref(prop_info, retval, (zobj->ce->__get->common.fn_flags & ZEND_ACC_STRICT_TYPES) != 0);
747748
}
748749

@@ -757,8 +758,9 @@ ZEND_API zval *zend_std_read_property(zval *object, zval *member, int type, void
757758
}
758759
}
759760

760-
if ((type != BP_VAR_IS)) {
761-
if (UNEXPECTED(prop_info = zend_object_fetch_property_type_info(Z_OBJCE_P(object), name, cache_slot))) {
761+
if (type != BP_VAR_IS) {
762+
if (IS_VALID_PROPERTY_OFFSET(property_offset) &&
763+
(prop_info = zend_object_fetch_property_type_info(Z_OBJCE_P(object), name, cache_slot))) {
762764
zend_throw_error(NULL, "Typed property %s::$%s must not be accessed before initialization",
763765
ZSTR_VAL(prop_info->ce->name),
764766
ZSTR_VAL(name));

0 commit comments

Comments
 (0)