]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.1939: invalid memory access in Ex mode with global command v8.2.1939
authorBram Moolenaar <Bram@vim.org>
Sun, 1 Nov 2020 20:56:40 +0000 (21:56 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 1 Nov 2020 20:56:40 +0000 (21:56 +0100)
Problem:    Invalid memory access in Ex mode with global command.
Solution:   Make sure the cursor is on a valid line. (closes #7238)

src/move.c
src/testdir/test_ex_mode.vim
src/version.c

index 20a34e8e56aa5e156f5d2c75cc56fd294fc61894..cd0af3e64f477b17ee5abc6a4a4e6211d7f110fa 100644 (file)
@@ -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;
index 32c65448f4902acc267a66aaa6b3b488ccdaadc9..c9ec20e54f21f29630aa08675eb0af04e9b2510f 100644 (file)
@@ -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
index 3cba21401f26d47e0419495724a020b8e51b0e37..b4ef5a98373ae23e0b72d43bebe664cb57a477fb 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1939,
 /**/
     1938,
 /**/