Skip to content

Commit 1a08a3e

Browse files
committed
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.
1 parent c174c2e commit 1a08a3e

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/edit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,12 +2438,12 @@ stop_insert(
24382438
* otherwise CTRL-O w and then <Left> will clear "last_insert".
24392439
*/
24402440
ptr = get_inserted();
2441-
if (did_restart_edit == 0 || (ptr != NULL
2442-
&& (int)STRLEN(ptr) > new_insert_skip))
2441+
int added = ptr == NULL ? 0 : (int)STRLEN(ptr) - new_insert_skip;
2442+
if (did_restart_edit == 0 || added > 0)
24432443
{
24442444
vim_free(last_insert);
24452445
last_insert = ptr;
2446-
last_insert_skip = new_insert_skip;
2446+
last_insert_skip = added < 0 ? 0 : new_insert_skip;
24472447
}
24482448
else
24492449
vim_free(ptr);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1429,
698700
/**/
699701
1428,
700702
/**/

0 commit comments

Comments
 (0)