From 0a9c116bfa42170e9d3c7c016bde0fa21582b1b5 Mon Sep 17 00:00:00 2001 From: Dave Mitchell Date: Tue, 5 Jul 2005 13:01:23 +0000 Subject: [PATCH] change 24943 broke restoration of localized taint values p4raw-id: //depot/perl@25081 --- mg.c | 11 +++++++---- t/op/taint.t | 24 +++++++++++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/mg.c b/mg.c index 086ab9a..9ae88c4 100644 --- a/mg.c +++ b/mg.c @@ -1921,10 +1921,13 @@ int Perl_magic_settaint(pTHX_ SV *sv, MAGIC *mg) { PERL_UNUSED_ARG(sv); - if (PL_tainted) - mg->mg_len |= 1; - else - mg->mg_len &= ~1; + /* update taint status unless we're restoring at scope exit */ + if (PL_localizing != 2) { + if (PL_tainted) + mg->mg_len |= 1; + else + mg->mg_len &= ~1; + } return 0; } diff --git a/t/op/taint.t b/t/op/taint.t index 119e419..9089d04 100755 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -17,7 +17,7 @@ use Config; use File::Spec::Functions; BEGIN { require './test.pl'; } -plan tests => 238; +plan tests => 243; $| = 1; @@ -1106,3 +1106,25 @@ TERNARY_CONDITIONALS: { test not any_tainted @bar; } } + +# at scope exit, a restored localised value should have its old +# taint status, not the taint status of the current statement + +{ + our $x99 = $^X; + test tainted $x99; + + $x99 = ''; + test not tainted $x99; + + my $c = do { local $x99; $^X }; + test not tainted $x99; +} +{ + our $x99 = $^X; + test tainted $x99; + + my $c = do { local $x99; '' }; + test tainted $x99; +} + -- 1.8.3.1