diff options
author | Father Chrysostomos <sprout@cpan.org> | 2015-07-20 11:23:49 -0700 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2015-08-21 14:37:26 +0100 |
commit | 913281cacd3442109f345cc20d38e78a36470f94 (patch) | |
tree | 874336900bd5804267e2404d794642250c61dba1 | |
parent | 7018e207a4aba9fdbe423ecf0c2dcf49b5ad2eb7 (diff) | |
download | perl-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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; |