1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix virtual properties in get_class_vars() (GH-15494)

Fixes GH-15456
This commit is contained in:
Ilija Tovilo
2024-08-19 17:39:31 +02:00
committed by GitHub
parent 60f87f29bb
commit b6d7c011b8
3 changed files with 24 additions and 1 deletions

2
NEWS
View File

@@ -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

View File

@@ -0,0 +1,20 @@
--TEST--
GH-15456: Crash in get_class_vars() on virtual properties
--FILE--
<?php
class C {
public $a = 42;
public $b = 42 { get => $this->b * 2; }
public $c { get => 42; }
}
var_dump(get_class_vars(C::class));
?>
--EXPECT--
array(2) {
["a"]=>
int(42)
["b"]=>
int(42)
}

View File

@@ -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;