From: Niko Tyni Subject: Fix stack pointer corruption in pp_concat() with 'use encoding' Bug-Debian: http://bugs.debian.org/596105 Bug: http://rt.perl.org/rt3/Ticket/Display.html?id=78674 Origin: upstream, http://perl5.git.perl.org/perl.git/commit/e3393f51d48d8b790e26324eb0336fac9689fa46 If the stack is reallocated during pp_concat() and 'use encoding' in effect, the stack pointer gets corrupted, causing memory allocation bugs and the like. --- pp_hot.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/pp_hot.c b/pp_hot.c index 3371e88..e9cccf3 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -271,6 +271,8 @@ PP(pp_concat) rbyte = !DO_UTF8(right); } if (lbyte != rbyte) { + /* sv_utf8_upgrade_nomg() may reallocate the stack */ + PUTBACK; if (lbyte) sv_utf8_upgrade_nomg(TARG); else { @@ -279,6 +281,7 @@ PP(pp_concat) sv_utf8_upgrade_nomg(right); rpv = SvPV_const(right, rlen); } + SPAGAIN; } sv_catpvn_nomg(TARG, rpv, rlen); -- tg: (c823880..) fixes/concat-stack-corruption (depends on: upstream)