0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.2.1972: crash when recreating nested fold

Problem:    Crash when recreating nested fold.
Solution:   Check for empty growarray. (closes #7278)
This commit is contained in:
Bram Moolenaar
2020-11-10 18:23:52 +01:00
parent c56936e2ba
commit 5e1f22ff61
3 changed files with 16 additions and 1 deletions

View File

@@ -640,7 +640,10 @@ foldCreate(linenr_T start, linenr_T end)
break; 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) if (ga_grow(gap, 1) == OK)

View File

@@ -844,4 +844,14 @@ func Test_move_no_folds()
bwipe! bwipe!
endfunc endfunc
" this was crashing
func Test_fold_create_delete_create()
new
fold
fold
normal zd
fold
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1972,
/**/ /**/
1971, 1971,
/**/ /**/