0
0
mirror of https://github.com/vim/vim.git synced 2025-11-16 23:24:03 -05:00

patch 9.0.0020: with some completion reading past end of string

Problem:    With some completion reading past end of string.
Solution:   Check the length of the string.
This commit is contained in:
Bram Moolenaar
2022-07-01 19:58:30 +01:00
parent eb273cd7b0
commit f12129f171
3 changed files with 22 additions and 2 deletions

View File

@@ -2209,11 +2209,21 @@ ins_compl_stop(int c, int prev_mode, int retval)
// but only do this, if the Popup is still visible
if (c == Ctrl_E)
{
char_u *p = NULL;
ins_compl_delete();
if (compl_leader != NULL)
ins_bytes(compl_leader + get_compl_len());
p = compl_leader;
else if (compl_first_match != NULL)
ins_bytes(compl_orig_text + get_compl_len());
p = compl_orig_text;
if (p != NULL)
{
int compl_len = get_compl_len();
int len = (int)STRLEN(p);
if (len > compl_len)
ins_bytes_len(p + compl_len, len - compl_len);
}
retval = TRUE;
}