summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2013-03-06 16:55:19 +0000
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2013-03-06 16:55:19 +0000
commit82ba7a81cfdc43426b7faaa9ad82dc1f8cf5f247 (patch)
treea1515156c5eef71ee7201370c39acf6b4016aead
parentae271f001f6290a5e494d846ab5a78f5abe79752 (diff)
downloadperl-maint-5.12.tar.gz
Fix memory leak in Encode.xsmaint-5.12
-rw-r--r--cpan/Encode/Encode.xs8
1 files 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);
}