summaryrefslogtreecommitdiffstats
path: root/src/insexpand.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-07-01 19:58:30 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-01 19:58:30 +0100
commitf12129f1714f7d2301935bb21d896609bdac221c (patch)
treece05cd5c868065408da749d38e96e8002830368d /src/insexpand.c
parenteb273cd7b036c35ae9070bd6352101914f273e71 (diff)
patch 9.0.0020: with some completion reading past end of stringv9.0.0020
Problem: With some completion reading past end of string. Solution: Check the length of the string.
Diffstat (limited to 'src/insexpand.c')
-rw-r--r--src/insexpand.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/insexpand.c b/src/insexpand.c
index 4a5feac9dc..734550ffd2 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -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;
}