diff options
-rw-r--r-- | mg.c | 2 | ||||
-rwxr-xr-x | t/op/magic.t | 19 |
2 files changed, 19 insertions, 2 deletions
@@ -818,7 +818,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) break; case '\\': if (PL_ors_sv) - sv_setpv(sv,SvPVX(PL_ors_sv)); + sv_copypv(sv, PL_ors_sv); break; case '#': sv_setpv(sv,PL_ofmt); diff --git a/t/op/magic.t b/t/op/magic.t index cbf8564497..0619c0dc34 100755 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -36,7 +36,7 @@ sub skip { return 1; } -print "1..48\n"; +print "1..50\n"; $Is_MSWin32 = $^O eq 'MSWin32'; $Is_NetWare = $^O eq 'NetWare'; @@ -324,3 +324,20 @@ ok ${^TAINT} == 0; ok "@-" eq "0 0 2 7"; ok "@+" eq "10 1 6 10"; +# Tests for the magic get of $\ +{ + my $ok = 0; + # [perl #19330] + { + local $\ = undef; + $\++; $\++; + $ok = $\ eq 2; + } + ok $ok; + $ok = 0; + { + local $\ = "a\0b"; + $ok = "a$\b" eq "aa\0bb"; + } + ok $ok; +} |