0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

updated for version 7.3.286

Problem:    Crash when using "zd" on a large number of folds. (Sam King)
Solution:   Recompute pointer after reallocating array.  Move fewer entries
            when making room.
This commit is contained in:
Bram Moolenaar
2011-08-26 16:13:00 +02:00
parent 792826c0c7
commit c9927c136f
2 changed files with 8 additions and 3 deletions

View File

@@ -1469,11 +1469,14 @@ deleteFoldEntry(gap, idx, recursive)
} }
else else
{ {
/* move nested folds one level up, to overwrite the fold that is /* Move nested folds one level up, to overwrite the fold that is
* deleted. */ * deleted. */
moved = fp->fd_nested.ga_len; moved = fp->fd_nested.ga_len;
if (ga_grow(gap, (int)(moved - 1)) == OK) if (ga_grow(gap, (int)(moved - 1)) == OK)
{ {
/* Get "fp" again, the array may have been reallocated. */
fp = (fold_T *)gap->ga_data + idx;
/* adjust fd_top and fd_flags for the moved folds */ /* adjust fd_top and fd_flags for the moved folds */
nfp = (fold_T *)fp->fd_nested.ga_data; nfp = (fold_T *)fp->fd_nested.ga_data;
for (i = 0; i < moved; ++i) for (i = 0; i < moved; ++i)
@@ -1486,9 +1489,9 @@ deleteFoldEntry(gap, idx, recursive)
} }
/* move the existing folds down to make room */ /* move the existing folds down to make room */
if (idx < gap->ga_len) if (idx + 1 < gap->ga_len)
mch_memmove(fp + moved, fp + 1, mch_memmove(fp + moved, fp + 1,
sizeof(fold_T) * (gap->ga_len - idx)); sizeof(fold_T) * (gap->ga_len - (idx + 1)));
/* move the contained folds one level up */ /* move the contained folds one level up */
mch_memmove(fp, nfp, (size_t)(sizeof(fold_T) * moved)); mch_memmove(fp, nfp, (size_t)(sizeof(fold_T) * moved));
vim_free(nfp); vim_free(nfp);

View File

@@ -709,6 +709,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 */
/**/
286,
/**/ /**/
285, 285,
/**/ /**/