summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorsyber <syber@crazypanda.ru>2014-12-09 01:36:23 +0300
committerFather Chrysostomos <sprout@cpan.org>2014-12-08 16:08:52 -0800
commitc290e187228e365708b7d5a9ae53ad10c3c002c6 (patch)
treea623fad6fe753fd7b6aecd146ab6d70e5f160a24 /gv.c
parentd3ac2b769b5ecec58c3a4173895286445c881f8a (diff)
downloadperl-c290e187228e365708b7d5a9ae53ad10c3c002c6.tar.gz
Fix gv_fetchmeth_sv: it might stringify SV more than once.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gv.c b/gv.c
index 96e07da425..68018162f1 100644
--- a/gv.c
+++ b/gv.c
@@ -636,8 +636,14 @@ of an SV instead of a string/length pair.
GV *
Perl_gv_fetchmeth_sv(pTHX_ HV *stash, SV *namesv, I32 level, U32 flags)
{
- PERL_ARGS_ASSERT_GV_FETCHMETH_SV;
- return gv_fetchmeth_internal(stash, namesv, NULL, 0, level, flags);
+ char *namepv;
+ STRLEN namelen;
+ PERL_ARGS_ASSERT_GV_FETCHMETH_SV;
+ if (LIKELY(SvPOK_nog(namesv))) /* common case */
+ return gv_fetchmeth_internal(stash, namesv, NULL, 0, level, flags);
+ namepv = SvPV(namesv, namelen);
+ if (SvUTF8(namesv)) flags |= SVf_UTF8;
+ return gv_fetchmeth_pvn(stash, namepv, namelen, level, flags);
}
/*