From 82ba7a81cfdc43426b7faaa9ad82dc1f8cf5f247 Mon Sep 17 00:00:00 2001 From: Chris 'BinGOs' Williams Date: Wed, 6 Mar 2013 16:55:19 +0000 Subject: Fix memory leak in Encode.xs --- cpan/Encode/Encode.xs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpan/Encode/Encode.xs b/cpan/Encode/Encode.xs index b2e912785f..c44d8f3f4b 100644 --- a/cpan/Encode/Encode.xs +++ b/cpan/Encode/Encode.xs @@ -435,7 +435,6 @@ CODE: if (src == &PL_sv_undef) src = 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 @@ -466,6 +465,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 */ @@ -477,7 +477,7 @@ CODE: SvCUR_set(src, slen); } SvUTF8_on(dst); - ST(0) = sv_2mortal(dst); + ST(0) = dst; XSRETURN(1); } @@ -499,7 +499,7 @@ CODE: if (src == &PL_sv_undef) src = 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)) { @@ -538,7 +538,7 @@ CODE: } SvPOK_only(dst); SvUTF8_off(dst); - ST(0) = sv_2mortal(dst); + ST(0) = dst; XSRETURN(1); } -- cgit v1.2.1