patch 9.0.1378: illegal memory access when using virtual editing
Problem: Illegal memory access when using virtual editing.
Solution: Make sure "startspaces" is not negative.
diff --git a/src/register.c b/src/register.c
index 461363b..f3df79c 100644
--- a/src/register.c
+++ b/src/register.c
@@ -1245,6 +1245,8 @@
// double-count it.
bd.startspaces = (ce - cs + 1)
- oap->start.coladd;
+ if (bd.startspaces < 0)
+ bd.startspaces = 0;
startcol++;
}
}
diff --git a/src/testdir/test_virtualedit.vim b/src/testdir/test_virtualedit.vim
index 71cea42..edaae67 100644
--- a/src/testdir/test_virtualedit.vim
+++ b/src/testdir/test_virtualedit.vim
@@ -88,6 +88,16 @@
set virtualedit=
endfunc
+func Test_edit_special_char()
+ new
+ se ve=all
+ norm a0
+ 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()
diff --git a/src/version.c b/src/version.c
index a9cf30e..c93499c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1378,
+/**/
1377,
/**/
1376,