summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2015-07-20 11:23:49 -0700
committerFather Chrysostomos <sprout@cpan.org>2015-07-24 05:56:57 -0700
commitd2fcb1d6773910aef058d59681ff6ae649f68352 (patch)
tree38e83a66ce01ba7359bb029817041b80c9e5f9cd /gv.c
parent56022c66b16bfc6b3aa117972e6ebb4c3acb03f7 (diff)
downloadperl-d2fcb1d6773910aef058d59681ff6ae649f68352.tar.gz
[perl #125541] Fix crash with %::=(); J->${\"::"}
gv_stashpvn does not expect gv_fetchpv to return something that is not a GV. If someone has blown away the stash with %::=(), then the $::{"main::"} entry no longer exists, but gv_fetchpv expects it to be there. This patch just makes this case fail somewhat gracefully instead of crashing: $ ./miniperl -e '%::=(); J->${\"::"}' Can't locate object method "" via package "" (perhaps you forgot to load ""?) at -e line 1. If someone does %::=(), nothing more reasonable should be expected. At least it does not crash now.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index 821a3834b8..651a7aa76f 100644
--- a/gv.c
+++ b/gv.c
@@ -1411,7 +1411,7 @@ S_gv_stashpvn_internal(pTHX_ const char *name, U32 namelen, I32 flags)
tmpgv = gv_fetchpvn_flags(tmpbuf, tmplen, flags, SVt_PVHV);
if (tmpbuf != smallbuf)
Safefree(tmpbuf);
- if (!tmpgv)
+ if (!tmpgv || !isGV_with_GP(tmpgv))
return NULL;
stash = GvHV(tmpgv);
if (!(flags & ~GV_NOADD_MASK) && !stash) return NULL;