Skip to content

Commit 8097bbb

Browse files
committed
Fix assertion failure in zend_std_read_property
1 parent 396b995 commit 8097bbb

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

Zend/tests/gh16615_001.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
GH-16615 001 (Assertion failure in zend_std_read_property)
3+
--FILE--
4+
<?php
5+
6+
class Foo {
7+
public string $bar {
8+
set => $value;
9+
}
10+
}
11+
12+
$reflector = new ReflectionClass(Foo::class);
13+
14+
// Adds IS_PROP_LAZY to prop flags
15+
$foo = $reflector->newLazyGhost(function ($ghost) {
16+
$ghost->bar = 'bar';
17+
});
18+
19+
echo $foo->bar;
20+
21+
?>
22+
--EXPECT--
23+
bar

Zend/tests/gh16615_002.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-16615 002 (Assertion failure in zend_std_read_property)
3+
--FILE--
4+
<?php
5+
6+
class Foo {
7+
public string $bar {
8+
set => $value;
9+
}
10+
public function __clone() {
11+
try {
12+
echo $this->bar;
13+
} catch (Error $e) {
14+
printf("%s: %s\n", $e::class, $e->getMessage());
15+
}
16+
}
17+
}
18+
19+
// Adds IS_PROP_REINITABLE to prop flags
20+
clone new Foo();
21+
22+
?>
23+
--EXPECT--
24+
Error: Typed property Foo::$bar must not be accessed before initialization

Zend/zend_object_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int
791791
if (UNEXPECTED(Z_TYPE_P(retval) == IS_UNDEF)) {
792792
/* As hooked properties can't be unset, the only way to end up with an undef
793793
* value is via an uninitialized property. */
794-
ZEND_ASSERT(Z_PROP_FLAG_P(retval) == IS_PROP_UNINIT);
794+
ZEND_ASSERT(Z_PROP_FLAG_P(retval) & IS_PROP_UNINIT);
795795
goto uninit_error;
796796
}
797797

0 commit comments

Comments
 (0)