Skip to content

Fix GH-25266: Misaligned read in ReflectionProperty::isReadable() - #25271

Closed
lazerg wants to merge 2 commits into
php:PHP-8.6from
lazerg:fix/gh-25266
Closed

lazerg wants to merge 2 commits into
php:PHP-8.6from
lazerg:fix/gh-25266

Conversation

@lazerg

@lazerg lazerg commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Internal classes like DOMDocument declare virtual properties without hooks, backed by the object handlers. #21769 stopped asserting on those, but when an object is passed isReadable() still falls into the declared-property branch and reads OBJ_PROP(obj, prop->offset), which is not a real slot for a virtual property. This returns true for virtual properties without hooks, same as isWritable() already does for non-readonly ones.

Fixes #25266

Comment thread ext/reflection/php_reflection.c Outdated
Comment on lines +6747 to +6752
@@ -6748,6 +6748,8 @@ ZEND_METHOD(ReflectionProperty, isReadable)
if (!prop->hooks[ZEND_PROPERTY_HOOK_GET]) {
RETURN_FALSE;
}
} else if (prop->flags & ZEND_ACC_VIRTUAL) {
RETURN_TRUE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RETURN_TRUE;
if (prop->flags & ZEND_ACC_VIRTUAL) {
if (prop->hooks && !prop->hooks[ZEND_PROPERTY_HOOK_GET]) {
RETURN_FALSE;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems bughub messed up the diff, but I hope you see the point

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, merged the two branches in 81140cb.

@ndossche ndossche closed this in 4927938 Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants