X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=mg.c;h=931b1a1525174dd499072690cdddb7e7695a4c13;hb=5ca69f12fe2141395f51c7675a4c54f19c907231;hp=eb79dc469a5762254d0a7f1118a8cee60cdcf3e4;hpb=aea4f609175b8d3694278560443a821f9cb5265c;p=p5sagit%2Fp5-mst-13.2.git diff --git a/mg.c b/mg.c index eb79dc4..931b1a1 100644 --- a/mg.c +++ b/mg.c @@ -412,7 +412,9 @@ Perl_magic_len(pTHX_ SV *sv, MAGIC *mg) char *s = rx->subbeg + s1; char *send = rx->subbeg + t1; - i = Perl_utf8_length(aTHX_ (U8*)s, (U8*)send); + i = t1 - s1; + if (is_utf8_string((U8*)s, i)) + i = Perl_utf8_length(aTHX_ (U8*)s, (U8*)send); } if (i < 0) Perl_croak(aTHX_ "panic: magic_len: %"IVdf, (IV)i); @@ -630,7 +632,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) PL_tainted = FALSE; } sv_setpvn(sv, s, i); - if (DO_UTF8(PL_reg_sv)) + if (DO_UTF8(PL_reg_sv) && is_utf8_string((U8*)s, i)) SvUTF8_on(sv); else SvUTF8_off(sv);