From: Nicholas Clark Date: Sat, 6 Dec 2003 16:30:35 +0000 (+0000) Subject: Make sv_force_normal_flags cope with shared hash key scalars X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5c98da1c029548d157089bc95672bf854902dd76;p=p5sagit%2Fp5-mst-13.2.git Make sv_force_normal_flags cope with shared hash key scalars (remember the pointer from SvPVX, reset the flags before SvGROW, avoid crazy loops or read-from-free) p4raw-id: //depot/perl@21854 --- diff --git a/sv.c b/sv.c index 5e61449..dc089b8 100644 --- a/sv.c +++ b/sv.c @@ -4497,14 +4497,17 @@ Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags) if (SvREADONLY(sv)) { if (SvFAKE(sv)) { char *pvx = SvPVX(sv); + int is_utf8 = SvUTF8(sv); STRLEN len = SvCUR(sv); U32 hash = SvUVX(sv); SvFAKE_off(sv); SvREADONLY_off(sv); + SvPVX(sv) = 0; + SvLEN(sv) = 0; SvGROW(sv, len + 1); Move(pvx,SvPVX(sv),len,char); *SvEND(sv) = '\0'; - unsharepvn(pvx, SvUTF8(sv) ? -(I32)len : len, hash); + unsharepvn(pvx, is_utf8 ? -(I32)len : len, hash); } else if (IN_PERL_RUNTIME) Perl_croak(aTHX_ PL_no_modify);