summaryrefslogtreecommitdiffstats
path: root/src/insexpand.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-27 19:28:37 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-27 19:28:37 +0000
commit4b28ba3245df8274303c79429972f9dc9438e4aa (patch)
tree13be14eddf43b5129c33f2e0f00182da700f574f /src/insexpand.c
parentaf4a61a85d6e8cacc35324f266934bc463a21673 (diff)
patch 8.2.3915: illegal memory access when completing with invalid bytesv8.2.3915
Problem: illegal memory access when completing with invalid bytes. Solution: Avoid going over the end of the completion text.
Diffstat (limited to 'src/insexpand.c')
-rw-r--r--src/insexpand.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/insexpand.c b/src/insexpand.c
index b0319a26ed..9fb7fb7269 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -3437,7 +3437,12 @@ ins_compl_delete(void)
void
ins_compl_insert(int in_compl_func)
{
- ins_bytes(compl_shown_match->cp_str + ins_compl_len());
+ int compl_len = ins_compl_len();
+
+ // Make sure we don't go over the end of the string, this can happen with
+ // illegal bytes.
+ if (compl_len < (int)STRLEN(compl_shown_match->cp_str))
+ ins_bytes(compl_shown_match->cp_str + compl_len);
if (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT)
compl_used_match = FALSE;
else