]> granicus.if.org Git - vim/commitdiff
patch 8.2.1947: crash when using "zj" without folds v8.2.1947
authorBram Moolenaar <Bram@vim.org>
Tue, 3 Nov 2020 19:05:40 +0000 (20:05 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 3 Nov 2020 19:05:40 +0000 (20:05 +0100)
Problem:    Crash when using "zj" without folds. (Sean Dewar)
Solution:   Check for at least one fold. (closes #7245)

src/fold.c
src/testdir/test_fold.vim
src/version.c

index 8a904f64c6a26ef6b9a0d909059bf82cde2f051e..4b4e6182997ee4c06ef2a3d3ff3f6ba3a20a26c3 100644 (file)
@@ -902,6 +902,8 @@ foldMoveTo(
        // that moves the cursor is used.
        lnum_off = 0;
        gap = &curwin->w_folds;
+       if (gap->ga_len == 0)
+           break;
        use_level = FALSE;
        maybe_small = FALSE;
        lnum_found = curwin->w_cursor.lnum;
index 62244640bf443cfc3fe38a350ee92040cc975936..f0bd6e481dc4ef9623d1fd6e2383b9e5edd86157 100644 (file)
@@ -835,4 +835,13 @@ func Test_undo_fold_deletion()
   bwipe!
 endfunc
 
+" this was crashing
+func Test_move_no_folds()
+  new
+  fold
+  setlocal fdm=expr
+  normal zj
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 3f2affe3b4a66a649725bbf770167d22d448a812..015cf4cb17ab7c6545c4a5409a4a9ec72231ef59 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1947,
 /**/
     1946,
 /**/