From: Vincent Pit Date: Thu, 10 Sep 2009 16:20:06 +0000 (+0200) Subject: Don't modify namelen in the first half of gv_stashpvn() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=add0ecdee09ea286dc942aff3ba4215ab63f5059;p=p5sagit%2Fp5-mst-13.2.git Don't modify namelen in the first half of gv_stashpvn() As it may be needed later when the lookup failed. This fixes [perl #69066]. However, from now, "package ::" and "package foo::" respectively introduce the "::" and "foo::" packages. Deciding if this is the correct thing to do ought to be addressed separately. --- diff --git a/gv.c b/gv.c index c97d99c..3df4e27 100644 --- a/gv.c +++ b/gv.c @@ -855,17 +855,18 @@ Perl_gv_stashpvn(pTHX_ const char *name, U32 namelen, I32 flags) char *tmpbuf; HV *stash; GV *tmpgv; + U32 tmplen = namelen + 2; PERL_ARGS_ASSERT_GV_STASHPVN; - if (namelen + 2 <= sizeof smallbuf) + if (tmplen <= sizeof smallbuf) tmpbuf = smallbuf; else - Newx(tmpbuf, namelen + 2, char); - Copy(name,tmpbuf,namelen,char); - tmpbuf[namelen++] = ':'; - tmpbuf[namelen++] = ':'; - tmpgv = gv_fetchpvn_flags(tmpbuf, namelen, flags, SVt_PVHV); + Newx(tmpbuf, tmplen, char); + Copy(name, tmpbuf, namelen, char); + tmpbuf[namelen] = ':'; + tmpbuf[namelen+1] = ':'; + tmpgv = gv_fetchpvn_flags(tmpbuf, tmplen, flags, SVt_PVHV); if (tmpbuf != smallbuf) Safefree(tmpbuf); if (!tmpgv)