Skip to content

Commit 5e1f22f

Browse files
committed
patch 8.2.1972: crash when recreating nested fold
Problem: Crash when recreating nested fold. Solution: Check for empty growarray. (closes #7278)
1 parent c56936e commit 5e1f22f

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/fold.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,10 @@ foldCreate(linenr_T start, linenr_T end)
640640
break;
641641
}
642642
}
643-
i = (int)(fp - (fold_T *)gap->ga_data);
643+
if (gap->ga_len == 0)
644+
i = 0;
645+
else
646+
i = (int)(fp - (fold_T *)gap->ga_data);
644647
}
645648

646649
if (ga_grow(gap, 1) == OK)

src/testdir/test_fold.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,4 +844,14 @@ func Test_move_no_folds()
844844
bwipe!
845845
endfunc
846846

847+
" this was crashing
848+
func Test_fold_create_delete_create()
849+
new
850+
fold
851+
fold
852+
normal zd
853+
fold
854+
bwipe!
855+
endfunc
856+
847857
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1972,
753755
/**/
754756
1971,
755757
/**/

0 commit comments

Comments
 (0)