Skip to content

Commit

Permalink
patch 8.2.4217: illegal memory access when undo makes Visual area inv…
Browse files Browse the repository at this point in the history
…alid

Problem:    Illegal memory access when undo makes Visual area invalid.
Solution:   Correct the Visual area after undo.
  • Loading branch information
brammool committed Jan 25, 2022
1 parent 06b7722 commit 8d02ce1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/testdir/test_visual.vim
Expand Up @@ -1339,5 +1339,20 @@ func Test_visual_ex_copy_line()
bwipe!
endfunc

" This was leaving the end of the Visual area beyond the end of a line.
" Set 'undolevels' to start a new undo block.
func Test_visual_undo_deletes_last_line()
new
call setline(1, ["aaa", "ccc", "dyd"])
set undolevels=100
exe "normal obbbbbbbbbxbb\<Esc>"
set undolevels=100
/y
exe "normal ggvjfxO"
undo
normal gNU
bwipe!
endfunc


" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/undo.c
Expand Up @@ -3029,6 +3029,8 @@ u_undo_end(
}
}
#endif
if (VIsual_active)
check_pos(curbuf, &VIsual);

smsg_attr_keep(0, _("%ld %s; %s #%ld %s"),
u_oldcount < 0 ? -u_oldcount : u_oldcount,
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

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

0 comments on commit 8d02ce1

Please sign in to comment.