summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2016-07-07 17:03:29 +0100
committerDavid Mitchell <davem@iabyn.com>2016-07-07 17:06:58 +0100
commitfc0fe26a7d286480c1bb25f57e469ece575bb68d (patch)
tree35f349bbd88314d4787bc546fdb43831ee1d1a6e /sv.c
parent6fe82bd6d07db28c9792126ff851a29fe013401c (diff)
downloadperl-fc0fe26a7d286480c1bb25f57e469ece575bb68d.tar.gz
SEGV in "Subroutine redefined" warning
RT #128257 The following SEGVed: sub P::f{} undef *P::; *P::f =sub{}; due to the code which generates the "Subroutine STASH::NAME redefined" warning assuming that the GV always has a stash. Make it so that if it hasn't, the message changes to "Subroutine NAME redefined" rather than just crashing.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sv.c b/sv.c
index 1b7a283e1e..0cbe37180c 100644
--- a/sv.c
+++ b/sv.c
@@ -4074,14 +4074,18 @@ Perl_gv_setref(pTHX_ SV *const dstr, SV *const sstr)
CvCONST((const CV *)sref)
? cv_const_sv((const CV *)sref)
: NULL;
+ HV * const stash = GvSTASH((const GV *)dstr);
report_redefined_cv(
- sv_2mortal(Perl_newSVpvf(aTHX_
- "%"HEKf"::%"HEKf,
- HEKfARG(
- HvNAME_HEK(GvSTASH((const GV *)dstr))
- ),
- HEKfARG(GvENAME_HEK(MUTABLE_GV(dstr)))
- )),
+ sv_2mortal(
+ stash
+ ? Perl_newSVpvf(aTHX_
+ "%"HEKf"::%"HEKf,
+ HEKfARG(HvNAME_HEK(stash)),
+ HEKfARG(GvENAME_HEK(MUTABLE_GV(dstr))))
+ : Perl_newSVpvf(aTHX_
+ "%"HEKf,
+ HEKfARG(GvENAME_HEK(MUTABLE_GV(dstr))))
+ ),
cv,
CvCONST((const CV *)sref) ? &new_const_sv : NULL
);