summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-08 19:58:34 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-08 19:58:34 +0100
commit3a5b580ccfc4c8c7d52ecd8ccd1431eb99a05a0f (patch)
tree882b13c2629d4214ca09fd5f77c679bb6c0bbe56 /gv.c
parent8a280620fcbbc5f0c47b80ca2dc5d3eb208012ae (diff)
downloadperl-3a5b580ccfc4c8c7d52ecd8ccd1431eb99a05a0f.tar.gz
Fix bugs in e771aaa95f65a9c4 (reducing copying in gv_fetchpvn_flags)
Bug spotting and 1 fix by Jerry D. Hedden.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/gv.c b/gv.c
index 9e939372db..1ed129ed04 100644
--- a/gv.c
+++ b/gv.c
@@ -1052,27 +1052,28 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
len = name_cursor - name;
if (len > 0) {
- char *tmpbuf;
-
- if (name_cursor == ':') {
- tmpbuf = name;
+ const char *key;
+ if (*name_cursor == ':') {
+ key = name;
len += 2;
} else {
+ char *tmpbuf;
Newx(tmpbuf, len+2, char);
Copy(name, tmpbuf, len, char);
tmpbuf[len++] = ':';
tmpbuf[len++] = ':';
+ key = tmpbuf;
}
- gvp = (GV**)hv_fetch(stash,tmpbuf,len,add);
+ gvp = (GV**)hv_fetch(stash, key, len, add);
gv = gvp ? *gvp : NULL;
if (gv && gv != (const GV *)&PL_sv_undef) {
if (SvTYPE(gv) != SVt_PVGV)
- gv_init(gv, stash, tmpbuf, len, (add & GV_ADDMULTI));
+ gv_init(gv, stash, key, len, (add & GV_ADDMULTI));
else
GvMULTI_on(gv);
}
- if (tmpbuf != name)
- Safefree(tmpbuf);
+ if (key != name)
+ Safefree((char *)key);
if (!gv || gv == (const GV *)&PL_sv_undef)
return NULL;