From: Zeev Suraski Date: Mon, 21 Jul 2003 12:13:16 +0000 (+0000) Subject: Fix bug #24499 X-Git-Tag: BEFORE_ARG_INFO~155 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e72d8e826d790713b990b7f34d85320633da4e2;p=php Fix bug #24499 --- diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 78aa8af692..399f7bfab8 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -178,13 +178,25 @@ inline int zend_verify_property_access(zend_property_info *property_info, zend_c return 0; } +static inline zend_bool is_derived_class(zend_class_entry *child_class, zend_class_entry *parent_class) +{ + child_class = child_class->parent; + while (child_class) { + if (child_class == parent_class) { + return 1; + } + child_class = child_class->parent; + } + + return 0; +} + static inline zend_property_info *zend_get_property_info(zend_object *zobj, zval *member TSRMLS_DC) { zend_property_info *property_info = NULL; zend_property_info *scope_property_info; zend_bool denied_access = 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)) { @@ -203,6 +215,7 @@ static inline zend_property_info *zend_get_property_info(zend_object *zobj, zval } } if (EG(scope) != zobj->ce + && is_derived_class(zobj->ce, EG(scope)) && EG(scope) && zend_hash_quick_find(&EG(scope)->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, h, (void **) &scope_property_info)==SUCCESS && scope_property_info->flags & ZEND_ACC_PRIVATE) { diff --git a/tests/lang/bug24499.phpt b/tests/lang/bug24499.phpt new file mode 100755 index 0000000000..6ce56dbad7 --- /dev/null +++ b/tests/lang/bug24499.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #24499 (bogus handling of a public property as a private one) +--FILE-- +id = "bar"; + } +} + +$id = new Id(); +@$obj->foo = "bar"; +$id->tester($obj); +print_r($obj); +?> +--EXPECT-- +stdClass Object +( + [foo] => bar + [id] => bar +)