]> granicus.if.org Git - vim/commitdiff
patch 9.0.0360: crash when invalid line number on :for is ignored v9.0.0360
authorBram Moolenaar <Bram@vim.org>
Fri, 2 Sep 2022 15:47:16 +0000 (16:47 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 2 Sep 2022 15:47:16 +0000 (16:47 +0100)
Problem:    Crash when invalid line number on :for is ignored.
Solution:   Do not check breakpoint for non-existing line.

src/ex_docmd.c
src/testdir/test_eval_stuff.vim
src/version.c

index ae1f1959b715ae1a219f97b247626087ffbfabed..0b6b217121119e9ec88fa7f0779e73bf2438891c 100644 (file)
@@ -1068,7 +1068,7 @@ do_cmdline(
 
                    // Check for the next breakpoint at or after the ":while"
                    // or ":for".
-                   if (breakpoint != NULL)
+                   if (breakpoint != NULL && lines_ga.ga_len > current_line)
                    {
                        *breakpoint = dbg_find_breakpoint(
                               getline_equal(fgetline, cookie, getsourceline),
index 313d791850c003bfbe907b33d89e440567ea3d13..934286bbe8418abef444afd1cce9fb57e42aff3f 100644 (file)
@@ -1,6 +1,7 @@
 " Tests for various eval things.
 
 source view_util.vim
+source shared.vim
 
 function s:foo() abort
   try
@@ -87,6 +88,18 @@ func Test_for_over_null_string()
   let &enc = save_enc
 endfunc
 
+func Test_for_invalid_line_count()
+  let lines =<< trim END
+      111111111111111111111111 for line in ['one']
+      endfor
+  END
+  call writefile(lines, 'XinvalidFor')
+  " only test that this doesn't crash
+  call RunVim([], [], '-u NONE -e -s -S XinvalidFor -c qa')
+
+  call delete('XinvalidFor')
+endfunc
+
 func Test_readfile_binary()
   new
   call setline(1, ['one', 'two', 'three'])
index fa2d9d54e258c0282eafc64ade7d089a5ce90af7..4f2b3dcf15a41dda62e3ef6b68683caa84a2beef 100644 (file)
@@ -707,6 +707,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    360,
 /**/
     359,
 /**/