summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2012-09-23 22:48:42 +0200
committerNicholas Clark <nick@ccl4.org>2012-09-26 23:28:50 +0200
commitdc93d7fb33f6b20933ff809c56ba68b8513d02c8 (patch)
treec53760b75fc758da8609351c9a90ac0b729e6efc /sv.c
parentb3ebc22146bca162c8b7f92453024f9f7a965c0a (diff)
downloadperl-dc93d7fb33f6b20933ff809c56ba68b8513d02c8.tar.gz
Flush PL_stashcache when assigning a file handle to a typeglob.
File handles take priority over stashes for method dispatch. Assigning a file handle to a typeglob potentially creates a file handle where one did not exist before. As PL_stashcache only contains entries for names which unambiguously resolve to stashes, such a change may mean that PL_stashcache now contains an invalid entry. As it's hard to work out exactly which entries might be affected, simply flush the entire cache and let it rebuild itself.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index bd8afb7bbe..2417e86730 100644
--- a/sv.c
+++ b/sv.c
@@ -3883,6 +3883,14 @@ S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr)
assert(mg);
Perl_magic_clearisa(aTHX_ NULL, mg);
}
+ else if (stype == SVt_PVIO) {
+ DEBUG_o(Perl_deb(aTHX_ "glob_assign_ref clearing PL_stashcache\n"));
+ /* It's a cache. It will rebuild itself quite happily.
+ It's a lot of effort to work out exactly which key (or keys)
+ might be invalidated by the creation of the this file handle.
+ */
+ hv_clear(PL_stashcache);
+ }
break;
}
SvREFCNT_dec(dref);