Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin: avoid passing bad parent argument to op_sibling_splice #22874

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

mauke
Copy link
Contributor

@mauke mauke commented Dec 26, 2024

op_sibling_splice() is supposed to be called with a parent/child op pair as the first two arguments. But in op_sibling_splice(parent, pushop, 1, NULL), parent is not necessarily a parent of pushop; it can also be a grandparent. In practice, this is harmless, however, as the parent argument is only used when splicing the first or last sibling of an op chain, which is never the case here (as ensured by the argop checks).

So just avoid parent altogether and pass NULL as the first argument instead, which is a documented part of the op_sibling_splice() API (and will raise a proper error if our assumptions don't hold in the future).


  • This set of changes does not require a perldelta entry.

op_sibling_splice() is supposed to be called with a parent/child op pair
as the first two arguments. But in `op_sibling_splice(parent, pushop, 1,
NULL)`, `parent` is not necessarily a parent of `pushop`; it can also
be a grandparent. In practice, this is harmless, however, as the parent
argument is only used when splicing the first or last sibling of an op
chain, which is never the case here (as ensured by the `argop` checks).

So just avoid `parent` altogether and pass `NULL` as the first argument
instead, which is a documented part of the op_sibling_splice() API (and
will raise a proper error if our assumptions don't hold in the future).
@mauke mauke merged commit a73cdae into Perl:blead Dec 30, 2024
33 of 34 checks passed
@mauke mauke deleted the avoid-bad-parenting branch December 30, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants