From: Bram Moolenaar Date: Tue, 10 Nov 2020 17:23:52 +0000 (+0100) Subject: patch 8.2.1972: crash when recreating nested fold X-Git-Tag: v8.2.1972 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e1f22ff614821b8fc7294c9dd22765acd403aeb;p=vim patch 8.2.1972: crash when recreating nested fold Problem: Crash when recreating nested fold. Solution: Check for empty growarray. (closes #7278) --- diff --git a/src/fold.c b/src/fold.c index 4b4e61829..82ce7e707 100644 --- a/src/fold.c +++ b/src/fold.c @@ -640,7 +640,10 @@ foldCreate(linenr_T start, linenr_T end) break; } } - i = (int)(fp - (fold_T *)gap->ga_data); + if (gap->ga_len == 0) + i = 0; + else + i = (int)(fp - (fold_T *)gap->ga_data); } if (ga_grow(gap, 1) == OK) diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim index f0bd6e481..1377983ca 100644 --- a/src/testdir/test_fold.vim +++ b/src/testdir/test_fold.vim @@ -844,4 +844,14 @@ func Test_move_no_folds() bwipe! endfunc +" this was crashing +func Test_fold_create_delete_create() + new + fold + fold + normal zd + fold + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 91477bcef..e2affa79e 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1972, /**/ 1971, /**/