Check object_init_ex() in ReflectionMethod::createFromMethodName() - #22978
Closed
iliaal wants to merge 1 commit into
Closed
Check object_init_ex() in ReflectionMethod::createFromMethodName()#22978iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
iliaal
added a commit
to iliaal/php-src
that referenced
this pull request
Jul 31, 2026
The result was ignored, so calling the factory on an uninstantiable subclass ran on a NULL zend_object: object_init_ex() throws, sets the return value to NULL and reports FAILURE, and Z_REFLECTION_P() then offsets backwards from that NULL. Three other object_init_ex() calls in this file already test the result. Closes phpGH-22978
iliaal
force-pushed
the
fix/reflection-createfrommethodname-abstract
branch
from
July 31, 2026 16:04
da9a6ff to
16dfbeb
Compare
| object_init_ex(return_value, execute_data->This.value.ce ? execute_data->This.value.ce : reflection_method_ptr); | ||
| zend_class_entry *called_ce = execute_data->This.value.ce ? execute_data->This.value.ce : reflection_method_ptr; | ||
| if (UNEXPECTED(object_init_ex(return_value, called_ce) != SUCCESS)) { | ||
| return; |
Member
There was a problem hiding this comment.
should this use RETURN_THROWS()?
Contributor
Author
There was a problem hiding this comment.
Matched the three other object_init_ex() call sites in this file, which all use a plain return. Want me to switch all four to RETURN_THROWS()?
Member
There was a problem hiding this comment.
no need to switch them all for a bugfix branch, but would be helpful to add it for just this one
The result was ignored, so calling the factory on an uninstantiable subclass ran on a NULL zend_object: object_init_ex() throws, sets the return value to NULL and reports FAILURE, and Z_REFLECTION_P() then offsets backwards from that NULL. Other object_init_ex() calls in this file already test the result. Closes phpGH-22978
iliaal
force-pushed
the
fix/reflection-createfrommethodname-abstract
branch
from
July 31, 2026 16:36
16dfbeb to
9e5e100
Compare
DanielEScherzer
approved these changes
Jul 31, 2026
DanielEScherzer
left a comment
Member
There was a problem hiding this comment.
thanks, LGTM once CI passes
Member
|
@iliaal I think this needs to be included in NEWS for 8.4, 8.5, and master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
instantiate_reflection_method()ignores the result ofobject_init_ex(). On an uninstantiable subclass that call throws, sets the return value to NULL and reports FAILURE, and the helper then runsZ_REFLECTION_P()over the NULLzend_object, offsetting backwards out of the allocation.Segfaults on 8.4, 8.5 and master; 8.3 carries the same code.
ReflectionClass::newInstance(),newInstanceArgs()andnewInstanceWithoutConstructor()already test the result the same way. Found while reviewing #22968, which touches the same helper but does not cause this.