# HG changeset patch # User Bram Moolenaar # Date 1604264404 -3600 # Node ID 53b996eb5e76e9665d93573cea06b5b3351b0bbf # Parent d67c6dd3d99ba6c668dfd0c6b65737d7333f3ff7 patch 8.2.1939: invalid memory access in Ex mode with global command Commit: https://github.com/vim/vim/commit/3b6d57f2ce87dc5a4b1a50e1b0fd2aeaf72faae2 Author: Bram Moolenaar Date: Sun Nov 1 21:56:40 2020 +0100 patch 8.2.1939: invalid memory access in Ex mode with global command Problem: Invalid memory access in Ex mode with global command. Solution: Make sure the cursor is on a valid line. (closes https://github.com/vim/vim/issues/7238) diff --git a/src/move.c b/src/move.c --- a/src/move.c +++ b/src/move.c @@ -196,6 +196,7 @@ update_topline(void) // the cursor line. if (!screen_valid(TRUE) || curwin->w_height == 0) { + check_cursor_lnum(); curwin->w_topline = curwin->w_cursor.lnum; curwin->w_botline = curwin->w_topline; curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP; diff --git a/src/testdir/test_ex_mode.vim b/src/testdir/test_ex_mode.vim --- a/src/testdir/test_ex_mode.vim +++ b/src/testdir/test_ex_mode.vim @@ -1,6 +1,7 @@ " Test editing line in Ex mode (see :help Q and :help gQ). source check.vim +source shared.vim " Helper function to test editing line in Q Ex mode func Ex_Q(cmd) @@ -179,4 +180,28 @@ func Test_ex_mode_errors() quit endfunc +func Test_ex_mode_with_global() + CheckFeature timers + + " This will get stuck in Normal mode after the failed "J", use a timer to + " get going again. + let lines =<< trim END + call ch_logfile('logfile', 'w') + pedit + func FeedQ(id) + call feedkeys('Q', 't') + endfunc + call timer_start(10, 'FeedQ') + g/^/vi|HJ + call writefile(['done'], 'Xdidexmode') + qall! + END + call writefile(lines, 'Xexmodescript') + call assert_equal(1, RunVim([], [], '-e -s -S Xexmodescript')) + call assert_equal(['done'], readfile('Xdidexmode')) + + call delete('Xdidexmode') + call delete('Xexmodescript') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1939, +/**/ 1938, /**/ 1937,