diff options
author | Nicholas Clark <nick@ccl4.org> | 2003-03-25 22:59:17 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2003-03-26 21:14:33 +0000 |
commit | 10bcdfd6e8d70ea5a2c02616001cf97fce7f3e17 (patch) | |
tree | c819b0996ea7f237b1a6b5c030f62b61d5aa21a5 /sv.c | |
parent | 83cd6e83f6f67657e252f6e633e259439425d98a (diff) | |
download | perl-10bcdfd6e8d70ea5a2c02616001cf97fce7f3e17.tar.gz |
Re: [perl #21614] 5.8.0 Unbalanced string table refcount
Message-ID: <20030325225917.GE284@Bagpuss.unfortu.net>
p4raw-id: //depot/perl@19069
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -1585,8 +1585,15 @@ Perl_sv_grow(pTHX_ register SV *sv, register STRLEN newlen) newlen = 0xFFFF; #endif } - else + else { + /* This is annoying, because sv_force_normal_flags will fix the flags, + recurse into sv_grow to malloc a buffer of SvCUR(sv) + 1, then + return back to us, only for us to potentially realloc the buffer. + */ + if (SvIsCOW(sv)) + sv_force_normal_flags(sv, 0); s = SvPVX(sv); + } if (newlen > SvLEN(sv)) { /* need more room? */ if (SvLEN(sv) && s) { @@ -4448,11 +4455,11 @@ Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags) char *pvx = SvPVX(sv); STRLEN len = SvCUR(sv); U32 hash = SvUVX(sv); + SvFAKE_off(sv); + SvREADONLY_off(sv); SvGROW(sv, len + 1); Move(pvx,SvPVX(sv),len,char); *SvEND(sv) = '\0'; - SvFAKE_off(sv); - SvREADONLY_off(sv); unsharepvn(pvx, SvUTF8(sv) ? -(I32)len : len, hash); } else if (PL_curcop != &PL_compiling) |