diff --git a/NEWS b/NEWS index 3f6c29d7a59..467cfd31871 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ PHP NEWS . Fixed bug GH-19844 (Don't bail when closing resources on shutdown). (ilutov) . Fixed deprecation for default case statement followed by semicolon not being emitted. (theodorejb) + . Fixed bug GH-20177 (Accessing overridden private property in + get_object_vars() triggers assertion error). (ilutov) - DOM: . Fix getNamedItemNS() incorrect namespace check. (nielsdos) diff --git a/Zend/tests/gh20177.phpt b/Zend/tests/gh20177.phpt new file mode 100644 index 00000000000..fd69460067f --- /dev/null +++ b/Zend/tests/gh20177.phpt @@ -0,0 +1,25 @@ +--TEST-- +GH-20177: Access overridden private property in get_object_vars() +--FILE-- + +--EXPECT-- +array(1) { + ["prop"]=> + string(8) "A::$prop" +} diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index cca69e5d792..3c45aeef512 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -566,6 +566,11 @@ ZEND_API zend_result zend_check_property_access(const zend_object *zobj, zend_st return FAILURE; } } else { + /* We were looking for a protected property but found a private one + * belonging to the parent class. */ + if (property_info->flags & ZEND_ACC_PRIVATE) { + return FAILURE; + } ZEND_ASSERT(property_info->flags & ZEND_ACC_PROTECTED); } return SUCCESS;