0
0
mirror of https://github.com/vim/vim.git synced 2025-07-25 10:54:51 -04:00

patch 8.2.1553: crash in edit test

Problem:    Crash in edit test.
Solution:   Avoid using invalid pointer.
This commit is contained in:
Bram Moolenaar 2020-08-31 21:15:02 +02:00
parent 64f37d3090
commit 2c93c685e3
2 changed files with 29 additions and 21 deletions

View File

@ -608,13 +608,18 @@ foldCreate(linenr_T start, linenr_T end)
// Find the place to insert the new fold. // Find the place to insert the new fold.
gap = &curwin->w_folds; gap = &curwin->w_folds;
if (gap->ga_len == 0)
i = 0;
else
{
for (;;) for (;;)
{ {
if (!foldFind(gap, start_rel, &fp)) if (!foldFind(gap, start_rel, &fp))
break; break;
if (fp->fd_top + fp->fd_len > end_rel) if (fp->fd_top + fp->fd_len > end_rel)
{ {
// New fold is completely inside this fold: Go one level deeper. // New fold is completely inside this fold: Go one level
// deeper.
gap = &fp->fd_nested; gap = &fp->fd_nested;
start_rel -= fp->fd_top; start_rel -= fp->fd_top;
end_rel -= fp->fd_top; end_rel -= fp->fd_top;
@ -630,13 +635,14 @@ foldCreate(linenr_T start, linenr_T end)
} }
else else
{ {
// This fold and new fold overlap: Insert here and move some folds // This fold and new fold overlap: Insert here and move some
// inside the new fold. // folds inside the new fold.
break; break;
} }
} }
i = (int)(fp - (fold_T *)gap->ga_data); i = (int)(fp - (fold_T *)gap->ga_data);
}
if (ga_grow(gap, 1) == OK) if (ga_grow(gap, 1) == OK)
{ {
fp = (fold_T *)gap->ga_data + i; fp = (fold_T *)gap->ga_data + i;

View File

@ -754,6 +754,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 */
/**/
1553,
/**/ /**/
1552, 1552,
/**/ /**/