summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2015-07-20 11:23:49 -0700
committerSteve Hay <steve.m.hay@googlemail.com>2015-08-21 14:37:26 +0100
commit913281cacd3442109f345cc20d38e78a36470f94 (patch)
tree874336900bd5804267e2404d794642250c61dba1
parent7018e207a4aba9fdbe423ecf0c2dcf49b5ad2eb7 (diff)
downloadperl-913281cacd3442109f345cc20d38e78a36470f94.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. (cherry picked from commit d2fcb1d6773910aef058d59681ff6ae649f68352)
-rw-r--r--gv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index ce6847842c..6b17ae2bb4 100644
--- a/gv.c
+++ b/gv.c
@@ -1339,7 +1339,7 @@ Perl_gv_stashpvn(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;