summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op.c4
-rw-r--r--t/op/stash.t13
2 files changed, 14 insertions, 3 deletions
diff --git a/op.c b/op.c
index f9a12626d6..939b47869d 100644
--- a/op.c
+++ b/op.c
@@ -6937,14 +6937,14 @@ Perl_newXS_flags(pTHX_ const char *name, XSUBADDR_t subaddr,
}
else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
/* already defined (or promised) */
- /* XXX It's possible for this HvNAME_get to return null, and get passed into strEQ */
if (ckWARN(WARN_REDEFINE)) {
GV * const gvcv = CvGV(cv);
if (gvcv) {
HV * const stash = GvSTASH(gvcv);
if (stash) {
const char *redefined_name = HvNAME_get(stash);
- if ( strEQ(redefined_name,"autouse") ) {
+ if ( redefined_name &&
+ strEQ(redefined_name,"autouse") ) {
const line_t oldline = CopLINE(PL_curcop);
if (PL_parser && PL_parser->copline != NOLINE)
CopLINE_set(PL_curcop, PL_parser->copline);
diff --git a/t/op/stash.t b/t/op/stash.t
index 8132e9dcb8..d755f74775 100644
--- a/t/op/stash.t
+++ b/t/op/stash.t
@@ -7,7 +7,7 @@ BEGIN {
BEGIN { require "./test.pl"; }
-plan( tests => 55 );
+plan( tests => 56 );
# Used to segfault (bug #15479)
fresh_perl_like(
@@ -25,6 +25,17 @@ fresh_perl_is(
q(Insert a non-GV in a stash, under warnings 'once'),
);
+# Used to segfault, too
+SKIP: {
+ skip_if_miniperl('requires XS');
+ fresh_perl_is(
+ 'sub foo::bar{}; $mro::{get_mro}=*foo::bar; undef %foo::; require mro',
+ '',
+ { switches => [ '-w' ] },
+ q(Defining an XSUB over an existing sub with no stash under warnings),
+ );
+}
+
{
no warnings 'deprecated';
ok( defined %oedipa::maas::, q(stashes happen to be defined if not used) );