Check object_init_ex() in ReflectionMethod::createFromMethodName() - #211
Closed
iliaal wants to merge 2 commits into
Closed
Check object_init_ex() in ReflectionMethod::createFromMethodName()#211iliaal wants to merge 2 commits into
iliaal wants to merge 2 commits into
Conversation
ReflectionMethod::__construct() overwrote intern->ptr without releasing the previous Closure::__invoke() trampoline, and ReflectionClassConstant::__construct() overwrote the $name and $class slots without dropping their previous references. ReflectionFunction, ReflectionParameter and ReflectionProperty already release prior state on re-entry. Closes phpGH-22968
iliaal
force-pushed
the
fix/reflection-createfrommethodname-abstract
branch
from
July 31, 2026 16:04
de8040b to
da9a6ff
Compare
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
Owner
Author
|
Promoted upstream as php#22978. |
iliaal
force-pushed
the
fix/reflection-createfrommethodname-abstract
branch
from
July 31, 2026 16:04
da9a6ff to
16dfbeb
Compare
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 php#22968, which touches the same helper but does not cause this.