This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Safe 2.35 from CPAN
[perl5.git] / dist / Safe / Safe.pm
index 46e1e50..f00853e 100644 (file)
@@ -3,7 +3,7 @@ package Safe;
 use 5.003_11;
 use Scalar::Util qw(reftype refaddr);
 
-$Safe::VERSION = "2.34";
+$Safe::VERSION = "2.35";
 
 # *** Don't declare any lexicals above this point ***
 #
@@ -21,7 +21,7 @@ sub lexless_anon_sub {
     # Uses a closure (on $__ExPr__) to pass in the code to be executed.
     # (eval on one line to keep line numbers as expected by caller)
     eval sprintf
-    'package %s; %s sub { @_=(); eval q[my $__ExPr__;] . $__ExPr__; }',
+    'package %s; %s sub { @_=(); eval q[local *SIG; my $__ExPr__;] . $__ExPr__; }',
                 $_[0], $_[1] ? 'use strict;' : '';
 }
 
@@ -355,6 +355,8 @@ sub _clean_stash {
 
 sub reval {
     my ($obj, $expr, $strict) = @_;
+    die "Bad Safe object" unless $obj->isa('Safe');
+
     my $root = $obj->{Root};
 
     my $evalsub = lexless_anon_sub($root, $strict, $expr);
@@ -405,6 +407,7 @@ sub _find_code_refs {
 
 sub wrap_code_ref {
     my ($obj, $sub) = @_;
+    die "Bad safe object" unless $obj->isa('Safe');
 
     # wrap code ref $sub with _safe_call_sv so that, when called, the
     # execution will happen with the compartment fully 'in effect'.
@@ -440,6 +443,8 @@ sub wrap_code_ref {
 
 sub rdo {
     my ($obj, $file) = @_;
+    die "Bad Safe object" unless $obj->isa('Safe');
+
     my $root = $obj->{Root};
 
     my $sg = sub_generation();