summaryrefslogtreecommitdiff
path: root/t/op
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2017-07-28 08:13:06 +0100
committerSteve Hay <steve.m.hay@googlemail.com>2017-07-28 08:13:21 +0100
commit6035f919de13f70b44763ca492202f747d2c2758 (patch)
treee4e9c6050907c7881146c3ac439a573c6c940f50 /t/op
parentb94bb58ebced3c5efc16addcc8f60c26ffd5cccb (diff)
downloadperl-6035f919de13f70b44763ca492202f747d2c2758.tar.gz
[perl #128182] Fix crash with require $nonstring
If something other than a plain string (e.g. a reference or typeglob) whose stringified form contains a null character is passed to require() or do(), it crashes, as of v5.19.3-130-gc8028aa, because the code in question that handles the error tries to read fields of the scalar that are only valid if it is a string internally. (cherry picked from commit 08f800f8519574aea9e744ff83230fb93772652b)
Diffstat (limited to 't/op')
-rw-r--r--t/op/require_errors.t10
1 files changed, 9 insertions, 1 deletions
diff --git a/t/op/require_errors.t b/t/op/require_errors.t
index 3d3d0270f0..d57ee95700 100644
--- a/t/op/require_errors.t
+++ b/t/op/require_errors.t
@@ -8,7 +8,7 @@ BEGIN {
use strict;
use warnings;
-plan(tests => 17);
+plan(tests => 19);
my $nonfile = tempfile();
@@ -134,3 +134,11 @@ like $@, qr/^Can't locate strict\.pm\\0invalid: /, 'do nul check';
eval "require strict\0::invalid;";
like $@, qr/^syntax error at \(eval \d+\) line 1/, 'parse error with \0 in barewords module names';
+# Refs and globs that stringify with embedded nulls
+# These crashed from 5.20 to 5.24 [perl #128182].
+eval { no warnings 'syscalls'; require eval "qr/\0/" };
+like $@, qr/^Can't locate \(\?\^:\\0\):/,
+ 'require ref that stringifies with embedded null';
+eval { no strict; no warnings 'syscalls'; require *{"\0a"} };
+like $@, qr/^Can't locate \*main::\\0a:/,
+ 'require ref that stringifies with embedded null';