Skip to content

Commit

Permalink
Fix crash in .pull-one on IO::Handle.lines iterator
Browse files Browse the repository at this point in the history
That seems to occur with RI::Batch/RI::Rotor iterators or
when .pull-one is called manually.

The iterator calls .get() on the Handle that reads from its $!PIO
and when that's exhaused the $!PIO is set to null. So when the next
.pull-one is done, we try to .get() on a closed handle by attempting
to read from nqp::null() that $!PIO is now is.

Bug find: https://irclog.perlgeek.de/perl6-dev/2017-01-27#i_13996365
  • Loading branch information
zoffixznet committed Jan 27, 2017
1 parent 2734533 commit ede01c2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/core/IO/Handle.pm
Expand Up @@ -565,11 +565,15 @@ my class IO::Handle does IO {
nqp::create(self)!SET-SELF(handle, close);
}
method pull-one() is raw {
nqp::if(nqp::defined(my \g = $!handle.get),
g,
nqp::stmts(
nqp::if($!close, $!handle.close),
IterationEnd))
nqp::if(
nqp::isnull(
nqp::getattr(nqp::decont($!handle), $!handle.WHAT, '$!PIO')),
IterationEnd,
nqp::if(nqp::defined(my \g = $!handle.get),
g,
nqp::stmts(
nqp::if($!close, $!handle.close),
IterationEnd)))
}
method push-all($target --> IterationEnd) {
my $line;
Expand Down

0 comments on commit ede01c2

Please sign in to comment.