]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2176: crash with a sequence of fold commands v8.2.2176
authorBram Moolenaar <Bram@vim.org>
Mon, 21 Dec 2020 13:01:41 +0000 (14:01 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 21 Dec 2020 13:01:41 +0000 (14:01 +0100)
Problem:    Crash with a sequence of fold commands.
Solution:   Bail out when there are no folds at all.  Add a test (Dominique
            PellĂ©) (closes #7515)

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

index 82ce7e707de3e4bb6f9afcea8beda1096c0acef7..f889f4c74da150a61351747157a3820cd551f13f 100644 (file)
@@ -916,7 +916,7 @@ foldMoveTo(
        {
            if (!foldFind(gap, curwin->w_cursor.lnum - lnum_off, &fp))
            {
-               if (!updown)
+               if (!updown || gap->ga_len == 0)
                    break;
 
                // When moving up, consider a fold above the cursor; when
index 505ad02392d1a1fe138d09b7106b216ac7e1acba..b978fc080faad37da334a1741cc0a1fde5cfc4a3 100644 (file)
@@ -852,4 +852,11 @@ func Test_fold_create_delete_create()
   bwipe!
 endfunc
 
+" this was crashing
+func Test_fold_create_delete()
+  new
+  norm zFzFzdzj
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index e9c65bca545435c745ff67b6d7cacf0aec4cb88a..5ed39fe5346ae3278e5b2cbf72087511e6f41a9e 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2176,
 /**/
     2175,
 /**/