Skip to content

IO::Handle: Fix a spurious error reported for regular file handles #18035

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
Aug 11, 2020

Conversation

ppisar
Copy link
Contributor

@ppisar ppisar commented Aug 6, 2020

89341f8 fix for GH #6799 introduced a regression when calling error()
on an IO::Handle object that was opened for reading a regular file:

$ perl -e 'open my $f, q{<}, q{/etc/hosts} or die; print qq{error\n} if $f->error'
error

In case of a regular file opened for reading, IoOFP() returns NULL and
PerlIO_error(NULL) reports -1. Compare to the case of a file opened
for writing when both IoIFP() and IoOFP() return non-NULL, equaled
pointer.

This patch fixes handling the case of the NULL output stream.

GH #18019

89341f8 fix for GH Perl#6799 introduced a regression when calling error()
on an IO::Handle object that was opened for reading a regular file:

$ perl -e 'open my $f, q{<}, q{/etc/hosts} or die; print qq{error\n} if $f->error'
error

In case of a regular file opened for reading, IoOFP() returns NULL and
PerlIO_error(NULL) reports -1. Compare to the case of a file opened
for writing when both IoIFP() and IoOFP() return non-NULL, equaled
pointer.

This patch fixes handling the case of the NULL output stream.

GH Perl#18019
@khwilliamson khwilliamson merged commit 8a2562b into Perl:blead Aug 11, 2020
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