diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-24 21:40:14 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-08-25 06:53:59 +0800 |
commit | 5d1f0c3eca9675bfdeb75402ec3340d05cc34732 (patch) | |
tree | 67d434c0b4729ea0b45c5dd5f419832eb3e1d5bf /src | |
parent | c366a63e4cdd97fc2818be348186a18e1b6eb8df (diff) | |
download | rneovim-5d1f0c3eca9675bfdeb75402ec3340d05cc34732.tar.gz rneovim-5d1f0c3eca9675bfdeb75402ec3340d05cc34732.tar.bz2 rneovim-5d1f0c3eca9675bfdeb75402ec3340d05cc34732.zip |
vim-patch:9.0.0046: reading past end of completion with duplicate match
Problem: Reading past end of completion with duplicate match.
Solution: Check string length
https://github.com/vim/vim/commit/baefde14550231f6468ac2ed2ed495bc381c0c92
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/insexpand.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_ins_complete.vim | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 743537621b..2d470aa992 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -709,7 +709,7 @@ static int ins_compl_add(char_u *const str, int len, char_u *const fname, do { 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)) { FREE_CPTEXT(cptext, cptext_allocated); return NOTDONE; } diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 6c59041451..cd7d83c8ea 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -969,5 +969,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 |