This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add a taint test to catch codegen bug
authorGerard Goossen <gerard@ggoossen.net>
Tue, 21 Dec 2010 12:57:34 +0000 (13:57 +0100)
committerZefram <zefram@fysh.org>
Sat, 8 Jan 2011 13:38:39 +0000 (13:38 +0000)
New test covers something previously done wrong in the experimental
code-generation patch.

t/op/taint.t

index 99a6a59..e873ba2 100644 (file)
@@ -17,7 +17,7 @@ use Config;
 use File::Spec::Functions;
 
 BEGIN { require './test.pl'; }
-plan tests => 339;
+plan tests => 340;
 
 $| = 1;
 
@@ -1470,7 +1470,14 @@ end
     ::is($w, "", "RT 81230");
 }
 
-
+{
+    # Compiling a subroutine inside a tainted expression does not make the
+    # constant folded values tainted.
+    my $x = sub { "x" . "y" };
+    my $y = $ENV{PATH} . $x->(); # Compile $x inside a tainted expression
+    my $z = $x->();
+    ok( ! tainted($z), "Constants folded value not tainted");
+}
 
 # This may bomb out with the alarm signal so keep it last
 SKIP: {