]> granicus.if.org Git - vim/commitdiff
patch 9.0.1378: illegal memory access when using virtual editing v9.0.1378
authorBram Moolenaar <Bram@vim.org>
Sat, 4 Mar 2023 14:13:10 +0000 (14:13 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 4 Mar 2023 14:13:10 +0000 (14:13 +0000)
Problem:    Illegal memory access when using virtual editing.
Solution:   Make sure "startspaces" is not negative.

src/register.c
src/testdir/test_virtualedit.vim
src/version.c

index 461363be378d610d8268896d06f2d4ec99efcc64..f3df79cfd6426546926b7187c2eb8053eff8e9ac 100644 (file)
@@ -1245,6 +1245,8 @@ op_yank(oparg_T *oap, int deleting, int mess)
                                // double-count it.
                                bd.startspaces = (ce - cs + 1)
                                                          - oap->start.coladd;
+                               if (bd.startspaces < 0)
+                                   bd.startspaces = 0;
                                startcol++;
                            }
                        }
index 71cea427bac11eb3714b6ed30ec7ce3ab6ec284d..edaae678609dd5ec158ea710eb29c5e8eca177f1 100644 (file)
@@ -88,6 +88,16 @@ func Test_edit_change()
   set virtualedit=
 endfunc
 
+func Test_edit_special_char()
+  new
+  se ve=all
+  norm a\160
+  sil! exe "norm o00000\<Nul>k<a0s"
+
+  bwipe!
+  set virtualedit=
+endfunc
+
 " Tests for pasting at the beginning, end and middle of a tab character
 " in virtual edit mode.
 func Test_paste_in_tab()
index a9cf30e2f08013d946f70c6a458a14dfd00587e2..c93499c416b4cd8212860c63d1ca3fb74b570aa7 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1378,
 /**/
     1377,
 /**/