summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-03-04 14:13:10 +0000
committerBram Moolenaar <Bram@vim.org>2023-03-04 14:13:10 +0000
commitc99cbf8f289bdda5d4a77d7ec415850a520330ba (patch)
treed2e538394cb7a8a7c42a4aac6ccf1a8e3256999b
parent5c6a3c9bad67c2ce766f55dbecb3461f14833a42 (diff)
downloadvim-git-c99cbf8f289bdda5d4a77d7ec415850a520330ba.tar.gz
patch 9.0.1378: illegal memory access when using virtual editingv9.0.1378
Problem: Illegal memory access when using virtual editing. Solution: Make sure "startspaces" is not negative.
-rw-r--r--src/register.c2
-rw-r--r--src/testdir/test_virtualedit.vim10
-rw-r--r--src/version.c2
3 files changed, 14 insertions, 0 deletions
diff --git a/src/register.c b/src/register.c
index 461363be3..f3df79cfd 100644
--- a/src/register.c
+++ b/src/register.c
@@ -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++;
}
}
diff --git a/src/testdir/test_virtualedit.vim b/src/testdir/test_virtualedit.vim
index 71cea427b..edaae6786 100644
--- a/src/testdir/test_virtualedit.vim
+++ b/src/testdir/test_virtualedit.vim
@@ -88,6 +88,16 @@ func Test_edit_change()
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 a9cf30e2f..c93499c41 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1378,
+/**/
1377,
/**/
1376,