diff --git a/src/insexpand.c b/src/insexpand.c index 0ecb6560c5fc3..9c598a89f73dc 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -786,7 +786,8 @@ ins_compl_add( { if (!match_at_original_text(match) && STRNCMP(match->cp_str, str, len) == 0 - && match->cp_str[len] == NUL) + && ((int)STRLEN(match->cp_str) <= len + || match->cp_str[len] == NUL)) return NOTDONE; match = match->cp_next; } while (match != NULL && !is_first_match(match)); diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index 5e5b1bbece681..2be6d06020374 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -2112,5 +2112,15 @@ func Test_infercase_very_long_line() set noic noinfercase endfunc +func Test_ins_complete_add() + " this was reading past the end of allocated memory + new + norm o + norm 7o€€ + sil! norm o + + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 75de2fc7b7514..de8e968f42f8c 100644 --- a/src/version.c +++ b/src/version.c @@ -735,6 +735,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 46, /**/ 45, /**/