summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-04-03 22:32:16 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-04-03 22:32:36 -0700
commit57f45d7ba6658ede12e3850ae36f93319790c957 (patch)
tree2a208b286a0bcff5b8325e93d5b3247bb728a688 /sv.c
parent27fcb6ee0bb7765fc92447e27763fa4ab7ae9baa (diff)
downloadperl-57f45d7ba6658ede12e3850ae36f93319790c957.tar.gz
[perl #87664] Don’t autovivify stashes when anonymising CVs
This commit stops CV anonymisation from autovivifying stashes to point to (unless the stash is %__ANON__::). If a stash has been deleted from its original position in the symbol table, then its HvNAME will no longer indicate where to find it. S_anonymise_cv_maybe in sv.c was using the HvNAME to look up (and autovivify) the *__ANON__ glob in the stash, without taking into account that it might not actually be looking in the right spot. So now, after checking that the stash still has a name (HvNAME), it uses the HvENAME to find it. If the HvENAME is null, which indicates that the stash has been detached altogether, then %__ANON__:: is used, as happens when HvNAME is null. This solves a Class::Monadic failure introduced by commit 2d0d1eccfc ([perl #79208] %stash:: = () anonymises CVs), which was included in 5.13.7. Basically, it can be reduced to this:
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sv.c b/sv.c
index 9ea0b50c3f..447c2bc5ef 100644
--- a/sv.c
+++ b/sv.c
@@ -5991,7 +5991,8 @@ S_anonymise_cv_maybe(pTHX_ GV *gv, CV* cv)
}
/* if not, anonymise: */
- stash = GvSTASH(gv) ? HvNAME(GvSTASH(gv)) : NULL;
+ stash = GvSTASH(gv) && HvNAME(GvSTASH(gv))
+ ? HvENAME(GvSTASH(gv)) : NULL;
gvname = Perl_newSVpvf(aTHX_ "%s::__ANON__",
stash ? stash : "__ANON__");
anongv = gv_fetchsv(gvname, GV_ADDMULTI, SVt_PVCV);