Better fix for #119529
authorFather Chrysostomos <sprout@cpan.org>
Fri, 25 Oct 2013 13:15:30 +0000 (06:15 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 25 Oct 2013 15:15:14 +0000 (08:15 -0700)
commit5a2bc23bfe5dc60ff957cb44ffaa57668d56d238
treeae34e806720633a0e8591308baec84f0bfb1ff6d
parentf6d098c6aa26a223a4250725da6a7784102e19a6
Better fix for #119529

<$fh> used to loop if $fh was opened to an in-memory handle containing
a reference.

Commit 552908b174 fixed the loop by forcing a reference to a string
when the handle was created.  It did not take into account that the
reference might be read-only.  It was also insufficient, in that
the target scalar could be set to a reference after the handle
was created.

The real reason it was looping was that the code for returning and
setting the size of the buffer was not handling non-PVs properly
(unless they were globs, which were special-cased).  It might return
0, and it might not, depending on what the internal SV field hap-
pened to hold.

This caused looping under 5.12 and onwards, but even in 5.10 <$fh>
returned nothing.

In this case, deleting code makes things just work.

Reverting the hunk from 552908b174 stops appending to refs from work-
ing, so I tweaked PerlIOScalar_pushed to fix that (which also reduced
the amount of code).
ext/PerlIO-scalar/scalar.xs
ext/PerlIO-scalar/t/scalar.t