diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2005-01-23 23:25:01 +0200 |
---|---|---|
committer | Dave Mitchell <davem@fdisolutions.com> | 2005-01-23 22:20:10 +0000 |
commit | 128c951743744da884743c814b7b2e8304bf26d0 (patch) | |
tree | 2850f650a1b76907a5ef7f2d4fb845d243b155b6 /pp.c | |
parent | 8fdec51143ba8063c924c83e982d4e30db7fb7ae (diff) | |
download | perl-128c951743744da884743c814b7b2e8304bf26d0.tar.gz |
Re: Smoke [5.9.2] 23863 FAIL(F) MSWin32 WinXP/.Net SP1 (x86/1 cpu)
Message-Id: <41F3FA0D.4010301@iki.fi>
The uc() memory reduction patch had a memory leak...
p4raw-id: //depot/perl@23869
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -3583,8 +3583,10 @@ PP(pp_uc) SETs(TARG); } else { + STRLEN min = len + 1; + (void)SvUPGRADE(TARG, SVt_PV); - SvGROW(TARG, len + 1); + SvGROW(TARG, min); (void)SvPOK_only(TARG); d = (U8*)SvPVX(TARG); send = s + len; @@ -3592,14 +3594,16 @@ PP(pp_uc) STRLEN u = UTF8SKIP(s); toUPPER_utf8(s, tmpbuf, &ulen); - if (ulen > u) { + if (ulen > u && (SvLEN(TARG) < (min += ulen - u))) { + /* If the eventually required minimum size outgrows + * the available space, we need to grow. */ UV o = d - (U8*)SvPVX(TARG); /* If someone uppercases one million U+03B0s we * SvGROW() one million times. Or we could try * guessing how much to allocate without allocating * too much. Such is life. */ - SvGROW(TARG, SvLEN(TARG) + ulen - u); + SvGROW(TARG, min); d = (U8*)SvPVX(TARG) + o; } Copy(tmpbuf, d, ulen, U8); @@ -3662,8 +3666,10 @@ PP(pp_lc) SETs(TARG); } else { + STRLEN min = len + 1; + (void)SvUPGRADE(TARG, SVt_PV); - SvGROW(TARG, len + 1); + SvGROW(TARG, min); (void)SvPOK_only(TARG); d = (U8*)SvPVX(TARG); send = s + len; @@ -3690,14 +3696,16 @@ PP(pp_lc) * See lib/unicore/SpecialCasing.txt. */ } - if (ulen > u) { + if (ulen > u && (SvLEN(TARG) < (min += ulen - u))) { + /* If the eventually required minimum size outgrows + * the available space, we need to grow. */ UV o = d - (U8*)SvPVX(TARG); /* If someone lowercases one million U+0130s we * SvGROW() one million times. Or we could try * guessing how much to allocate without allocating. * too much. Such is life. */ - SvGROW(TARG, SvLEN(TARG) + ulen - u); + SvGROW(TARG, min); d = (U8*)SvPVX(TARG) + o; } Copy(tmpbuf, d, ulen, U8); |