Skip to content

Commit 412dd75

Browse files
committed
Perform checks for propertis started with '\\0' only for dynamic properties
1 parent 583616d commit 412dd75

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Zend/zend_object_handlers.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,6 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
364364
return (uintptr_t)CACHED_PTR_EX(cache_slot + 1);
365365
}
366366

367-
if (UNEXPECTED(ZSTR_VAL(member)[0] == '\0' && ZSTR_LEN(member) != 0)) {
368-
if (!silent) {
369-
zend_throw_error(NULL, "Cannot access property started with '\\0'");
370-
}
371-
return ZEND_WRONG_PROPERTY_OFFSET;
372-
}
373-
374367
if (UNEXPECTED(zend_hash_num_elements(&ce->properties_info) == 0)) {
375368
goto exit_dynamic;
376369
}
@@ -418,6 +411,12 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
418411
}
419412
} else if (UNEXPECTED(property_info == NULL)) {
420413
exit_dynamic:
414+
if (UNEXPECTED(ZSTR_VAL(member)[0] == '\0' && ZSTR_LEN(member) != 0)) {
415+
if (!silent) {
416+
zend_throw_error(NULL, "Cannot access property started with '\\0'");
417+
}
418+
return ZEND_WRONG_PROPERTY_OFFSET;
419+
}
421420
if (cache_slot) {
422421
CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET);
423422
}
@@ -445,13 +444,6 @@ ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_s
445444
uint32_t flags;
446445
zend_class_entry *scope;
447446

448-
if (UNEXPECTED(ZSTR_VAL(member)[0] == '\0' && ZSTR_LEN(member) != 0)) {
449-
if (!silent) {
450-
zend_throw_error(NULL, "Cannot access property started with '\\0'");
451-
}
452-
return ZEND_WRONG_PROPERTY_INFO;
453-
}
454-
455447
if (UNEXPECTED(zend_hash_num_elements(&ce->properties_info) == 0)) {
456448
goto exit_dynamic;
457449
}
@@ -495,6 +487,12 @@ ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_s
495487
property_info = (zend_property_info*)Z_PTR_P(zv);
496488
} else if (UNEXPECTED(property_info == NULL)) {
497489
exit_dynamic:
490+
if (UNEXPECTED(ZSTR_VAL(member)[0] == '\0' && ZSTR_LEN(member) != 0)) {
491+
if (!silent) {
492+
zend_throw_error(NULL, "Cannot access property started with '\\0'");
493+
}
494+
return ZEND_WRONG_PROPERTY_INFO;
495+
}
498496
return NULL;
499497
} else if (UNEXPECTED(property_info == ZEND_WRONG_PROPERTY_INFO)) {
500498
/* Information was available, but we were denied access. Error out. */

0 commit comments

Comments
 (0)