From: Graham Barr Date: Wed, 29 Oct 2003 09:56:53 +0000 (+0000) Subject: Re: [perl #24346] pulling in stuff from outside the substr lvalue X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b76f3ce2ec5581029cdf9bb8f9a8cc61fe6afee0;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #24346] pulling in stuff from outside the substr lvalue Message-Id: <3993BF6C-09F6-11D8-B6DD-0003938857CC@pobox.com> make a variable aliased to an lvalue substr value work as expected p4raw-id: //depot/perl@22414 --- diff --git a/mg.c b/mg.c index 340ab6a..51a12f1 100644 --- a/mg.c +++ b/mg.c @@ -1780,16 +1780,21 @@ Perl_magic_setsubstr(pTHX_ SV *sv, MAGIC *mg) sv_utf8_upgrade(lsv); sv_pos_u2b(lsv, &lvoff, &lvlen); sv_insert(lsv, lvoff, lvlen, tmps, len); + LvTARGLEN(sv) = sv_len_utf8(sv); SvUTF8_on(lsv); } else if (lsv && SvUTF8(lsv)) { sv_pos_u2b(lsv, &lvoff, &lvlen); + LvTARGLEN(sv) = len; tmps = (char*)bytes_to_utf8((U8*)tmps, &len); sv_insert(lsv, lvoff, lvlen, tmps, len); Safefree(tmps); } - else - sv_insert(lsv, lvoff, lvlen, tmps, len); + else { + sv_insert(lsv, lvoff, lvlen, tmps, len); + LvTARGLEN(sv) = len; + } + return 0; }