diff --git a/NEWS b/NEWS index 54018fcab1f..090a43b11c8 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ PHP NEWS . Fixed bug GH-15419 (Missing readonly+hook incompatibility check for readonly classes). (ilutov) . Fixed bug GH-15187 (Various hooked object iterator issues). (ilutov) + . Fixed bug GH-15456 (Crash in get_class_vars() on virtual properties). + (ilutov) 15 Aug 2024, PHP 8.4.0beta3 diff --git a/Zend/tests/property_hooks/gh15456.phpt b/Zend/tests/property_hooks/gh15456.phpt new file mode 100644 index 00000000000..10a7dbbfb04 --- /dev/null +++ b/Zend/tests/property_hooks/gh15456.phpt @@ -0,0 +1,20 @@ +--TEST-- +GH-15456: Crash in get_class_vars() on virtual properties +--FILE-- + $this->b * 2; } + public $c { get => 42; } +} +var_dump(get_class_vars(C::class)); + +?> +--EXPECT-- +array(2) { + ["a"]=> + int(42) + ["b"]=> + int(42) +} diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 245552d0946..377bc23c46b 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -724,7 +724,8 @@ static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, bool s if (((prop_info->flags & ZEND_ACC_PROTECTED) && !zend_check_protected(prop_info->ce, scope)) || ((prop_info->flags & ZEND_ACC_PRIVATE) && - prop_info->ce != scope)) { + prop_info->ce != scope) || + (prop_info->flags & ZEND_ACC_VIRTUAL)) { continue; } prop = NULL;