diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-12-05 23:10:25 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-12-08 18:44:28 -0800 |
commit | 67a057d6d88eb9aafa609d47fefa412673b99ff5 (patch) | |
tree | d903dc98f78ef87e6af2c0b80e4c39dff6c1cd65 /t/op/lex.t | |
parent | e3fdfe77a69de5c9746593dc75431d53cef4c9f4 (diff) | |
download | perl-67a057d6d88eb9aafa609d47fefa412673b99ff5.tar.gz |
toke.c: Make _charnames check more robust
Assuming that $^H{charnames} exists and contains a code ref can result
in crashes. See the tests in the diff.
It’s not a good idea to do $INC{"_charnames.pm"}++, but perl still
shouldn’t crash.
Diffstat (limited to 't/op/lex.t')
-rw-r--r-- | t/op/lex.t | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/t/op/lex.t b/t/op/lex.t index 0789077b5c..c009f2d13c 100644 --- a/t/op/lex.t +++ b/t/op/lex.t @@ -4,7 +4,7 @@ use warnings; require './test.pl'; -plan(tests => 4); +plan(tests => 7); { no warnings 'deprecated'; @@ -45,3 +45,26 @@ curr_test(3); } +fresh_perl_is( + 'BEGIN{ ++$_ for @INC{"charnames.pm","_charnames.pm"} } "\N{a}"', + 'Constant(\N{a}) unknown at - line 1, within string' . "\n" + ."Execution of - aborted due to compilation errors.\n", + { stderr => 1 }, + 'correct output (and no crash) when charnames cannot load for \N{...}' +); +fresh_perl_is( + 'BEGIN{ ++$_ for @INC{"charnames.pm","_charnames.pm"}; + $^H{charnames} = "foo" } "\N{a}"', + "Undefined subroutine &main::foo called at - line 2.\n" + ."Propagated at - line 2, within string\n" + ."Execution of - aborted due to compilation errors.\n", + { stderr => 1 }, + 'no crash when charnames cannot load and %^H holds string' +); +fresh_perl_is( + 'BEGIN{ ++$_ for @INC{"charnames.pm","_charnames.pm"} } "\N{a}"', + 'Constant(\N{a}) unknown at - line 1, within string' . "\n" + ."Execution of - aborted due to compilation errors.\n", + { stderr => 1 }, + 'no crash when charnames cannot load and %^H holds string reference' +); |