Skip to content

Commit 8d02ce1

Browse files
committed
patch 8.2.4217: illegal memory access when undo makes Visual area invalid
Problem: Illegal memory access when undo makes Visual area invalid. Solution: Correct the Visual area after undo.
1 parent 06b7722 commit 8d02ce1

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/testdir/test_visual.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,5 +1339,20 @@ func Test_visual_ex_copy_line()
13391339
bwipe!
13401340
endfunc
13411341

1342+
" This was leaving the end of the Visual area beyond the end of a line.
1343+
" Set 'undolevels' to start a new undo block.
1344+
func Test_visual_undo_deletes_last_line()
1345+
new
1346+
call setline(1, ["aaa", "ccc", "dyd"])
1347+
set undolevels=100
1348+
exe "normal obbbbbbbbbxbb\<Esc>"
1349+
set undolevels=100
1350+
/y
1351+
exe "normal ggvjfxO"
1352+
undo
1353+
normal gNU
1354+
bwipe!
1355+
endfunc
1356+
13421357

13431358
" vim: shiftwidth=2 sts=2 expandtab

src/undo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,8 @@ u_undo_end(
30293029
}
30303030
}
30313031
#endif
3032+
if (VIsual_active)
3033+
check_pos(curbuf, &VIsual);
30323034

30333035
smsg_attr_keep(0, _("%ld %s; %s #%ld %s"),
30343036
u_oldcount < 0 ? -u_oldcount : u_oldcount,

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
4217,
753755
/**/
754756
4216,
755757
/**/

0 commit comments

Comments
 (0)