Skip to content

check the IO object exists when writing to IO magic variables #20736

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

Merged
merged 1 commit into from
Jan 24, 2023

Conversation

tonycoz
Copy link
Contributor

@tonycoz tonycoz commented Jan 23, 2023

pp_select() ensures that the GV in PL_defoutgv has an IO object when it the default output is set, but can't prevent that GV being cleared afterwards, resulting in a seg fault when the variable is written.

To prevent this, check PL_defoutgv has an IO object before trying to write to it.

Fixes #20733

pp_select() ensures that the GV in PL_defoutgv has an IO object
when it the default output is set, but can't prevent that GV
being cleared afterwards, resulting in a seg fault when the
variable is written.

To prevent this, check PL_defoutgv has an IO object before trying
to write to it.

Fixes Perl#20733
@jkeenan
Copy link
Contributor

jkeenan commented Jan 24, 2023

Following a TDD approach, I applied a patch of t/io/defout.t only to blead and ran the test program. It failed due to segfault. I then tested the branch; make test_harness PASSed.

LGTM, but someone with more C-foo should review the changes to mg.c.

@tonycoz tonycoz merged commit af62106 into Perl:blead Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants