diff options
-rw-r--r-- | mg.c | 2 | ||||
-rw-r--r-- | t/op/substr.t | 6 |
2 files changed, 6 insertions, 2 deletions
@@ -2194,7 +2194,7 @@ Perl_magic_setsubstr(pTHX_ SV *sv, MAGIC *mg) sv_utf8_upgrade_nomg(lsv); lvoff = sv_pos_u2b_flags(lsv, lvoff, &lvlen, SV_CONST_RETURN); sv_insert_flags(lsv, lvoff, lvlen, tmps, len, 0); - newtarglen = sv_len_utf8(sv); + newtarglen = sv_or_pv_len_utf8(sv, tmps, len); SvUTF8_on(lsv); } else if (SvUTF8(lsv)) { diff --git a/t/op/substr.t b/t/op/substr.t index 4fb4f96455..1b7cf31082 100644 --- a/t/op/substr.t +++ b/t/op/substr.t @@ -23,7 +23,7 @@ $SIG{__WARN__} = sub { BEGIN { require './test.pl'; } -plan(386); +plan(387); run_tests() unless caller; @@ -855,6 +855,10 @@ $refee = bless ["\x{100}"], o::; $o::count = 0; () = substr $refee, 0; is $o::count, 1, 'rvalue substr calls overloading once on utf8 target'; +$o::count = 0; +$refee = ""; +${\substr $refee, 0} = bless ["\x{100}"], o::; +is $o::count, 1, 'assigning utf8 overload to substr lvalue calls ovld 1ce'; # [perl #7678] core dump with substr reference and localisation {$b="abcde"; local $k; *k=\substr($b, 2, 1);} |