Fixed the closure argument passing bug perl#72068
authorTim Bunce <Tim.Bunce@pobox.com>
Thu, 14 Jan 2010 14:50:03 +0000 (14:50 +0000)
committerRafael Garcia-Suarez <rgs@consttype.org>
Thu, 14 Jan 2010 21:41:20 +0000 (22:41 +0100)
dist/Safe/Safe.pm

index 476b9fd..41a7d44 100644 (file)
@@ -308,7 +308,11 @@ sub reval {
         for my $ret (@ret) { # edit (via alias) any CODE refs
             next unless (reftype($ret)||'') eq 'CODE';
             my $sub = $ret; # avoid closure problems
-            $ret = sub { Opcode::_safe_call_sv($root, $obj->{Mask}, $sub) };
+            $ret = sub {
+                my @args = @_; # lexical to close over
+                my $sub_with_args = sub { $sub->(@args) };
+                return Opcode::_safe_call_sv($root, $obj->{Mask}, $sub_with_args)
+            };
         }
     }