summaryrefslogtreecommitdiff
path: root/Zend/zend_object_handlers.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-09-27 14:58:26 +0200
committerNikita Popov <nikita.ppv@gmail.com>2018-09-27 14:58:26 +0200
commit5a4cb3edde32a6cc4bce6439abea21f3e6b4bbf6 (patch)
treedba68f89faa25934ef101ca291289e97467d88bc /Zend/zend_object_handlers.c
parent390b74ee34ac567cab7d6b07b130a16504bbc43c (diff)
downloadphp-git-5a4cb3edde32a6cc4bce6439abea21f3e6b4bbf6.tar.gz
Fix missing access errors for guarded properties
If a property access would normally result in a magic method call, but the property is subject to an active recursion guard, the access should behave as if the magic method does not exist. This commit fixes one instance where this was not the case -- we should have been generating a property access error, but instead the operation simply did not do anything.
Diffstat (limited to 'Zend/zend_object_handlers.c')
-rw-r--r--Zend/zend_object_handlers.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 05c970da8b..8703cc44dc 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -741,8 +741,10 @@ call_getter:
}
OBJ_RELEASE(zobj);
goto exit;
- } else if (UNEXPECTED(ZSTR_VAL(name)[0] == '\0') && ZSTR_LEN(name) != 0) {
- zend_bad_property_name();
+ } else if (UNEXPECTED(IS_WRONG_PROPERTY_OFFSET(property_offset))) {
+ /* Trigger the correct error */
+ zend_get_property_offset(zobj->ce, name, 0, NULL);
+ ZEND_ASSERT(EG(exception));
retval = &EG(uninitialized_zval);
goto exit;
}
@@ -808,12 +810,13 @@ found:
} else if (EXPECTED(!IS_WRONG_PROPERTY_OFFSET(property_offset))) {
goto write_std_property;
} else {
- if (UNEXPECTED(ZSTR_VAL(name)[0] == '\0') && ZSTR_LEN(name) != 0) {
- zend_bad_property_name();
- goto exit;
- }
+ /* Trigger the correct error */
+ zend_get_property_offset(zobj->ce, name, 0, NULL);
+ ZEND_ASSERT(EG(exception));
+ goto exit;
}
- } else if (EXPECTED(!IS_WRONG_PROPERTY_OFFSET(property_offset))) {
+ } else {
+ ZEND_ASSERT(!IS_WRONG_PROPERTY_OFFSET(property_offset));
write_std_property:
if (Z_REFCOUNTED_P(value)) {
if (Z_ISREF_P(value)) {
@@ -1053,11 +1056,13 @@ ZEND_API void zend_std_unset_property(zval *object, zval *member, void **cache_s
(*guard) |= IN_UNSET; /* prevent circular unsetting */
zend_std_call_unsetter(zobj, name);
(*guard) &= ~IN_UNSET;
+ } else if (UNEXPECTED(IS_WRONG_PROPERTY_OFFSET(property_offset))) {
+ /* Trigger the correct error */
+ zend_get_property_offset(zobj->ce, name, 0, NULL);
+ ZEND_ASSERT(EG(exception));
+ goto exit;
} else {
- if (UNEXPECTED(ZSTR_VAL(name)[0] == '\0') && ZSTR_LEN(name) != 0) {
- zend_bad_property_name();
- goto exit;
- }
+ /* Nothing to do: The property already does not exist. */
}
}