]> granicus.if.org Git - vim/commitdiff
patch 8.2.3489: ml_get error after search with range v8.2.3489
authorBram Moolenaar <Bram@vim.org>
Sat, 9 Oct 2021 12:58:55 +0000 (13:58 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 9 Oct 2021 12:58:55 +0000 (13:58 +0100)
Problem:    ml_get error after search with range.
Solution:   Limit the line number to the buffer line count.

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

index 2c55e67bc3701d80015a0c7a2a0ceac2053246dd..08a48305ed0bcba8cb3d73828187ebc7d4563013 100644 (file)
@@ -4229,8 +4229,10 @@ get_address(
 
                    // When '/' or '?' follows another address, start from
                    // there.
-                   if (lnum != MAXLNUM)
-                       curwin->w_cursor.lnum = lnum;
+                   if (lnum > 0 && lnum != MAXLNUM)
+                       curwin->w_cursor.lnum =
+                               lnum > curbuf->b_ml.ml_line_count
+                                          ? curbuf->b_ml.ml_line_count : lnum;
 
                    // Start a forward search at the end of the line (unless
                    // before the first line).
index bb4e45defa65d3831b76ccef159501361bb29124..eaf9c232691386a48dd1072fa8b9fdd406138ed6 100644 (file)
@@ -1989,5 +1989,19 @@ func Test_no_last_search_pattern()
   call feedkeys("??\<C-T>", 'xt')
 endfunc
 
+func Test_search_with_invalid_range()
+  new
+  let lines =<< trim END
+    /\%.v
+    5/
+    c
+  END
+  call writefile(lines, 'Xrangesearch')
+  source Xrangesearch
+
+  bwipe!
+  call delete('Xrangesearch')
+endfunc
+
 
 " vim: shiftwidth=2 sts=2 expandtab
index f3fbd45bc280ee61358a3128e9e9f88065743460..43f87aabec709e07c2f024d2ffcd02aa32f18440 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3489,
 /**/
     3488,
 /**/