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);
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);
case '.':
#ifndef lint
if (GvIO(PL_last_in_gv)) {
- sv_setiv(sv, (IV)IoLINES(GvIO(PL_last_in_gv)));
+ sv_setiv(sv, (IV)IoLINES(GvIOp(PL_last_in_gv)));
}
#endif
break;