summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-15 13:33:04 -0400
committerJesse Luehrs <doy@tozt.net>2013-07-15 13:33:04 -0400
commit09635b7d339deb8916bd6426ccc94392b172f066 (patch)
treeeead52461c9ff9e7ccf21ecb3fc0469a776a080b
parent61b742169ef5342fa9e52be035ad9b68b98faee8 (diff)
downloadpackage-stash-xs-09635b7d339deb8916bd6426ccc94392b172f066.tar.gz
package-stash-xs-09635b7d339deb8916bd6426ccc94392b172f066.zip
make sure to do all fetches with the proper context
If we're fetching a glob for the purposes of writing to it, it shouldn't trigger read magic. The way to suppress that in calls to hv_fetch_ent is to pass a true value as the 'lval' parameter, which we were already doing elsewhere, just not in _expand_glob. get_all_symbols is only used for reading purposes, so it should unconditionally trigger read magic.
-rw-r--r--XS.xs8
1 files changed, 4 insertions, 4 deletions
diff --git a/XS.xs b/XS.xs
index 1a1be34..a3cd205 100644
--- a/XS.xs
+++ b/XS.xs
@@ -372,7 +372,7 @@ static void _real_gv_init(GV *gv, HV *stash, SV *name)
}
}
-static void _expand_glob(SV *self, SV *varname)
+static void _expand_glob(SV *self, SV *varname, int lval)
{
HV *namespace;
HE *entry;
@@ -380,7 +380,7 @@ static void _expand_glob(SV *self, SV *varname)
namespace = _get_namespace(self);
- if (entry = hv_fetch_ent(namespace, varname, 0, 0)) {
+ if (entry = hv_fetch_ent(namespace, varname, lval, 0)) {
glob = (GV*)HeVAL(entry);
if (isGV(glob)) {
croak("_expand_glob called on stash slot with expanded glob: %"SVf,
@@ -514,7 +514,7 @@ static SV *_get_symbol(SV *self, varspec_t *variable, int vivify)
glob = (GV*)(HeVAL(entry));
if (!isGV(glob))
- _expand_glob(self, variable->name);
+ _expand_glob(self, variable->name, vivify);
if (vivify && !_slot_exists(glob, variable->type)) {
_add_symbol(self, *variable, NULL);
@@ -921,7 +921,7 @@ get_all_symbols(self, vartype=VAR_NONE)
if (!isGV(gv)) {
SV *keysv = newSVpvn(key, len);
- _expand_glob(self, keysv);
+ _expand_glob(self, keysv, 0);
SvREFCNT_dec(keysv);
}