From: Abhijit Menon-Sen Date: Fri, 13 Jul 2001 05:21:16 +0000 (+0530) Subject: Re: Memory corruption? Read-only $_? X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4e83176dc97b70fd8935f6665dde17ce46d5f85f;p=p5sagit%2Fp5-mst-13.2.git Re: Memory corruption? Read-only $_? Message-ID: <20010713052116.B5669@lustre.dyn.wiw.org> p4raw-id: //depot/perl@11330 --- diff --git a/sv.c b/sv.c index 2bf9ada..12a5b87 100644 --- a/sv.c +++ b/sv.c @@ -1569,8 +1569,18 @@ Perl_sv_grow(pTHX_ register SV *sv, register STRLEN newlen) #endif Renew(s,newlen,char); } - else - New(703,s,newlen,char); + else { + /* If we're growing a newSVpvn_share()d SV, we must unshare + the PVX by hand, since sv_force_normal_flags() will try + to grow the SV. AMS 20010713 */ + if (SvREADONLY(sv) && SvFAKE(sv)) { + STRLEN len = SvCUR(sv); + SvFAKE_off(sv); + SvREADONLY_off(sv); + unsharepvn(SvPVX(sv), SvUTF8(sv) ? -(I32)len : len, SvUVX(sv)); + } + New(703, s, newlen, char); + } SvPV_set(sv, s); SvLEN_set(sv, newlen); }