]> granicus.if.org Git - php/commitdiff
Fix error handling in illegal property access
authorZeev Suraski <zeev@php.net>
Thu, 13 Feb 2003 22:47:25 +0000 (22:47 +0000)
committerZeev Suraski <zeev@php.net>
Thu, 13 Feb 2003 22:47:25 +0000 (22:47 +0000)
Zend/zend_object_handlers.c

index 1ec1599961414bad37c4d49779de4b4aaaded679..4e3ed31f64319c67fd8ca63555f2a5fe8fb69f60 100644 (file)
@@ -180,16 +180,23 @@ inline int zend_verify_property_access(zend_property_info *property_info, zend_c
 static inline zend_property_info *zend_get_property_info(zend_object *zobj, zval *member TSRMLS_DC)
 {
        zend_property_info *property_info;
+       zend_bool found_info_in_object = 0;
 
        ulong h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member)+1);
        if (zend_hash_quick_find(&zobj->ce->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, h, (void **) &property_info)==SUCCESS) {
-               if (!zend_verify_property_access(property_info, zobj->ce TSRMLS_CC)) {
-                       zend_error(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), zobj->ce->name, Z_STRVAL_P(member));
+               if (zend_verify_property_access(property_info, zobj->ce TSRMLS_CC)) {
+                       return property_info;
+               } else {
+                       found_info_in_object = 1;
                }
-       } else if (EG(scope)
-                               && zend_hash_quick_find(&EG(scope)->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, h, (void **) &property_info)==SUCCESS
-                               && property_info->flags & ZEND_ACC_PRIVATE) {
+       }
+       if (EG(scope)
+               && zend_hash_quick_find(&EG(scope)->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, h, (void **) &property_info)==SUCCESS
+               && property_info->flags & ZEND_ACC_PRIVATE) {
                /* ok */
+       } else if (found_info_in_object) {
+               /* Information was available, but we were denied access.  Error out. */
+               zend_error(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), zobj->ce->name, Z_STRVAL_P(member));
        } else {
                EG(std_property_info).flags = ZEND_ACC_PUBLIC;
                EG(std_property_info).name = Z_STRVAL_P(member);