Skip to content

Commit

Permalink
patch 9.0.1378: illegal memory access when using virtual editing
Browse files Browse the repository at this point in the history
Problem:    Illegal memory access when using virtual editing.
Solution:   Make sure "startspaces" is not negative.
  • Loading branch information
brammool committed Mar 4, 2023
1 parent 5c6a3c9 commit c99cbf8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/register.c
Expand Up @@ -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++;
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/testdir/test_virtualedit.vim
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1378,
/**/
1377,
/**/
Expand Down

0 comments on commit c99cbf8

Please sign in to comment.