diff options
author | Bram Moolenaar <bram@vim.org> | 2011-08-26 16:13:00 +0200 |
---|---|---|
committer | Bram Moolenaar <bram@vim.org> | 2011-08-26 16:13:00 +0200 |
commit | d6f3890e73042ddb3ae058db0f2749826f58e4cc (patch) | |
tree | e7d4a02a34a2fdf59c291a56d7b320df89aa755f | |
parent | 084d04a3dcfe433ae59b696e76564dd1a7896c65 (diff) | |
download | vim-d6f3890e73042ddb3ae058db0f2749826f58e4cc.tar.gz |
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.
-rw-r--r-- | src/fold.c | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 8 insertions, 3 deletions
@@ -1469,11 +1469,14 @@ deleteFoldEntry(gap, idx, recursive) } 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. */ moved = fp->fd_nested.ga_len; 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 */ nfp = (fold_T *)fp->fd_nested.ga_data; for (i = 0; i < moved; ++i) @@ -1486,9 +1489,9 @@ deleteFoldEntry(gap, idx, recursive) } /* 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, - sizeof(fold_T) * (gap->ga_len - idx)); + sizeof(fold_T) * (gap->ga_len - (idx + 1))); /* move the contained folds one level up */ mch_memmove(fp, nfp, (size_t)(sizeof(fold_T) * moved)); vim_free(nfp); diff --git a/src/version.c b/src/version.c index da8d97e0..51f1d256 100644 --- a/src/version.c +++ b/src/version.c @@ -710,6 +710,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 286, +/**/ 285, /**/ 284, |