This commit corrects the one remaining code path in
pp_ctl.c:S_run_user_filter that was not handling non-PVs.
If we have to truncate $_ and keep the remainder in a cache (because
it has more than one line), we need to make sure we don’t assume it is
a PV when it comes to truncating it.
$ ./perl -Ilib -e '@INC = sub { sub { return 0 if $|--; $_ = *{"foo;\nbar"}; return 1 } }; do "foo"'
Assertion failed: (!isGV_with_GP(upstream)), function S_run_user_filter, file pp_ctl.c, line 5494.
Abort trap: 6
if (SvUTF8(upstream)) {
SvUTF8_on(cache);
}
- SvCUR_set(upstream, got_len - cached_len);
+ if (SvPOK(upstream)) SvCUR_set(upstream, got_len - cached_len);
+ else
+ /* Cannot just use sv_setpvn, as that could free the buffer
+ before we have a chance to assign it. */
+ sv_usepvn(upstream, savepvn(got_p, got_len - cached_len),
+ got_len - cached_len);
*prune_from = 0;
/* Can't yet be EOF */
if (status == 0)
use Config;
use Filter::Util::Call;
-plan(tests => 151);
+plan(tests => 152);
unshift @INC, sub {
no warnings 'uninitialized';
@lines = ('$::the_array = "', do { no warnings 'once'; *foo}, '"');
do \&generator or die;
is ${$::{the_array}}, "*main::foo", 'setting $_ to glob in inc filter';
+@lines = (
+ '$::the_array = "',
+ do { no strict; no warnings; *{"foo\nbar"}},
+ '"');
+do \&generator or die;
+is ${$::{the_array}}, "*main::foo\nbar",
+ 'setting $_ to multiline glob in inc filter';
sub TIESCALAR { bless \(my $thing = pop), shift }
sub FETCH {${$_[0]}}