0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -04:00

patch 9.0.1429: invalid memory access when ending insert mode

Problem:    Invalid memory access when ending insert mode.
Solution:   Check if the insert_skip value is valid.
This commit is contained in:
Bram Moolenaar
2023-03-26 21:27:24 +01:00
parent c174c2e58c
commit 1a08a3e2a5
2 changed files with 5 additions and 3 deletions

View File

@@ -2438,12 +2438,12 @@ stop_insert(
* otherwise CTRL-O w and then <Left> will clear "last_insert". * otherwise CTRL-O w and then <Left> will clear "last_insert".
*/ */
ptr = get_inserted(); ptr = get_inserted();
if (did_restart_edit == 0 || (ptr != NULL int added = ptr == NULL ? 0 : (int)STRLEN(ptr) - new_insert_skip;
&& (int)STRLEN(ptr) > new_insert_skip)) if (did_restart_edit == 0 || added > 0)
{ {
vim_free(last_insert); vim_free(last_insert);
last_insert = ptr; last_insert = ptr;
last_insert_skip = new_insert_skip; last_insert_skip = added < 0 ? 0 : new_insert_skip;
} }
else else
vim_free(ptr); vim_free(ptr);

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1429,
/**/ /**/
1428, 1428,
/**/ /**/