diff options
author | chansen <chansen@cpan.org> | 2013-03-03 22:43:53 +0100 |
---|---|---|
committer | Ricardo Signes <rjbs@cpan.org> | 2013-03-06 09:53:00 -0500 |
commit | bbe897dfad5c0643d0541674a5e2b6c7d8e564b3 (patch) | |
tree | 05ad39046b15c1cc543c67f4429d35390cc0d06e | |
parent | 716e2c337e3e23cdd15e2704f4768be04b1e6e25 (diff) | |
download | perl-bbe897dfad5c0643d0541674a5e2b6c7d8e564b3.tar.gz |
Encode: Fixed a memory leak that occurred in the UTF-8 encoding.
The decode and encode methods allocated a SV for the result, this SV
is passed to the process_utf8() function which may croak() if the
CHECK flag has FB_CROAK set.
-rw-r--r-- | cpan/Encode/Encode.xs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cpan/Encode/Encode.xs b/cpan/Encode/Encode.xs index bb48e5abd5..312ba3448b 100644 --- a/cpan/Encode/Encode.xs +++ b/cpan/Encode/Encode.xs @@ -440,7 +440,6 @@ CODE: if (src == &PL_sv_undef || SvROK(src)) src = sv_2mortal(newSV(0)); s = (U8 *) SvPV(src, slen); e = (U8 *) SvEND(src); - dst = newSV(slen>0?slen:1); /* newSV() abhors 0 -- inaba */ check = SvROK(check_sv) ? ENCODE_PERLQQ|ENCODE_LEAVE_SRC : SvIV(check_sv); /* * PerlIO check -- we assume the object is of PerlIO if renewed @@ -471,6 +470,7 @@ CODE: } } + dst = sv_2mortal(newSV(slen>0?slen:1)); /* newSV() abhors 0 -- inaba */ s = process_utf8(aTHX_ dst, s, e, check_sv, 0, strict_utf8(aTHX_ obj), renewed); /* Clear out translated part of source unless asked not to */ @@ -482,7 +482,7 @@ CODE: SvCUR_set(src, slen); } SvUTF8_on(dst); - ST(0) = sv_2mortal(dst); + ST(0) = dst; XSRETURN(1); } @@ -504,7 +504,7 @@ CODE: if (src == &PL_sv_undef || SvROK(src)) src = sv_2mortal(newSV(0)); s = (U8 *) SvPV(src, slen); e = (U8 *) SvEND(src); - dst = newSV(slen>0?slen:1); /* newSV() abhors 0 -- inaba */ + dst = sv_2mortal(newSV(slen>0?slen:1)); /* newSV() abhors 0 -- inaba */ if (SvUTF8(src)) { /* Already encoded */ if (strict_utf8(aTHX_ obj)) { @@ -543,7 +543,7 @@ CODE: } SvPOK_only(dst); SvUTF8_off(dst); - ST(0) = sv_2mortal(dst); + ST(0) = dst; XSRETURN(1); } |