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 | c9927c136f3e8933fc1ea4b043e0a0b8c12bd023 (patch) | |
tree | 5a9288fbfd626cac240768dbe37cf2e85d46966f /src/fold.c | |
parent | 792826c0c715e037d7cca4d1a671c3b325e801a0 (diff) | |
download | vim-git-c9927c136f3e8933fc1ea4b043e0a0b8c12bd023.tar.gz |
updated for version 7.3.286v7.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.
Diffstat (limited to 'src/fold.c')
-rw-r--r-- | src/fold.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/fold.c b/src/fold.c index 800db61ba..3b7a9597c 100644 --- a/src/fold.c +++ b/src/fold.c @@ -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); |