From: Larry Wall Date: Tue, 14 Mar 1995 00:43:53 +0000 (-0800) Subject: [fix s/// memory leak] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cb0b1708c66ad12be7ce52c00b9565faecc67579;p=p5sagit%2Fp5-mst-13.2.git [fix s/// memory leak] In fixing another bug I installed a nasty memory leak in s///. Here's the fix. Larry --- diff --git a/pp_ctl.c b/pp_ctl.c index cca1fc1..201c32e 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -114,6 +114,7 @@ PP(pp_substcont) SV *targ = cx->sb_targ; sv_catpvn(dstr, s, cx->sb_strend - s); + Safefree(SvPVX(targ)); SvPVX(targ) = SvPVX(dstr); SvCUR_set(targ, SvCUR(dstr)); SvLEN_set(targ, SvLEN(dstr)); diff --git a/pp_hot.c b/pp_hot.c index 7bfec4a..dedb217 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1451,6 +1451,7 @@ PP(pp_subst) safebase)); sv_catpvn(dstr, s, strend - s); + Safefree(SvPVX(TARG)); SvPVX(TARG) = SvPVX(dstr); SvCUR_set(TARG, SvCUR(dstr)); SvLEN_set(TARG, SvLEN(dstr));