require './test.pl';
-plan(tests => 4);
+plan(tests => 7);
{
no warnings 'deprecated';
}
+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'
+);
* validation. */
table = GvHV(PL_hintgv); /* ^H */
cvp = hv_fetchs(table, "charnames", FALSE);
- cv = *cvp;
- if (((rv = SvRV(cv)) != NULL)
- && ((stash = CvSTASH(rv)) != NULL))
+ if (cvp && (cv = *cvp) && SvROK(cv) && ((rv = SvRV(cv)) != NULL)
+ && SvTYPE(rv) == SVt_PVCV && ((stash = CvSTASH(rv)) != NULL))
{
const char * const name = HvNAME(stash);
if strEQ(name, "_charnames") {