diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-10-08 19:58:34 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-10-08 19:58:34 +0100 |
commit | 3a5b580ccfc4c8c7d52ecd8ccd1431eb99a05a0f (patch) | |
tree | 882b13c2629d4214ca09fd5f77c679bb6c0bbe56 /gv.c | |
parent | 8a280620fcbbc5f0c47b80ca2dc5d3eb208012ae (diff) | |
download | perl-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.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -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; |