GH-22354: support interfaces added by attribute validators in zend_compile_implements()#22355
Open
DanielEScherzer wants to merge 2 commits into
Open
GH-22354: support interfaces added by attribute validators in zend_compile_implements()#22355DanielEScherzer wants to merge 2 commits into
DanielEScherzer wants to merge 2 commits into
Conversation
TimWolla
reviewed
Jun 17, 2026
|
|
||
| zend_class_name *newInterfaceSet = erealloc( | ||
| scope->interface_names, | ||
| sizeof(zend_class_name) * scope->num_interfaces |
Member
There was a problem hiding this comment.
Multiplication for allocations is unsafe. You need one of the _safe variants. The sizeof(zend_class_name) should also be sizeof(*newInterfaceSet).
Same for the allocations in zend_compile.
Member
Author
There was a problem hiding this comment.
Done, though at least in zend_compile this was matching existing multiplications
In `zend_compile_implements()`, when there were no interfaces already added, keep the existing code of just adding the newly declared interfaces. But, when some interfaces are already present, don't overwrite them. Instead, add to the existing list. In case the developer tries to add an interface that was already added by an attribute, skip the manual interface addition to avoid errors about trying to apply the same interface multiple times. But, only skip the *first* manual interface addition of the same interface, if there are multiple such additions then there really was an attempt to apply the same interface multiple times. Fixes php#22354
a911024 to
094b72f
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.
No description provided.