Skip to content

Commit 65b6056

Browse files
committed
patch 8.2.3409: reading beyond end of line with invalid utf-8 character
Problem: Reading beyond end of line with invalid utf-8 character. Solution: Check for NUL when advancing.
1 parent ddfc051 commit 65b6056

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Diff for: src/regexp_nfa.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -5664,7 +5664,8 @@ find_match_text(colnr_T startcol, int regstart, char_u *match_text)
56645664
match = FALSE;
56655665
break;
56665666
}
5667-
len2 += MB_CHAR2LEN(c2);
5667+
len2 += enc_utf8 ? utf_ptr2len(rex.line + col + len2)
5668+
: MB_CHAR2LEN(c2);
56685669
}
56695670
if (match
56705671
// check that no composing char follows

Diff for: src/testdir/test_regexp_utf8.vim

+8
Original file line numberDiff line numberDiff line change
@@ -558,4 +558,12 @@ func Test_match_char_class_upper()
558558
bwipe!
559559
endfunc
560560

561+
func Test_match_invalid_byte()
562+
call writefile(0z630a.765d30aa0a.2e0a.790a.4030, 'Xinvalid')
563+
new
564+
source Xinvalid
565+
bwipe!
566+
call delete('Xinvalid')
567+
endfunc
568+
561569
" vim: shiftwidth=2 sts=2 expandtab

Diff for: src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3409,
758760
/**/
759761
3408,
760762
/**/

0 commit comments

Comments
 (0)