]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1429: invalid memory access when ending insert mode v9.0.1429
authorBram Moolenaar <Bram@vim.org>
Sun, 26 Mar 2023 20:27:24 +0000 (21:27 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 26 Mar 2023 20:27:24 +0000 (21:27 +0100)
Problem:    Invalid memory access when ending insert mode.
Solution:   Check if the insert_skip value is valid.

src/edit.c
src/version.c

index 84b6eef4b6f1fe31285ea8756669de602afb8f5a..c23b0a8556b1bf5610e4a7e5ae6622e42a86b1e4 100644 (file)
@@ -2438,12 +2438,12 @@ stop_insert(
      * otherwise CTRL-O w and then <Left> will clear "last_insert".
      */
     ptr = get_inserted();
-    if (did_restart_edit == 0 || (ptr != NULL
-                                      && (int)STRLEN(ptr) > new_insert_skip))
+    int added = ptr == NULL ? 0 : (int)STRLEN(ptr) - new_insert_skip;
+    if (did_restart_edit == 0 || added > 0)
     {
        vim_free(last_insert);
        last_insert = ptr;
-       last_insert_skip = new_insert_skip;
+       last_insert_skip = added < 0 ? 0 : new_insert_skip;
     }
     else
        vim_free(ptr);
index f25f59fc843f9472ca93e8227b596d3d5e1d4efa..23e69b3433d5df6d624d8027ca3fc8fd792698ac 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1429,
 /**/
     1428,
 /**/