vim-patch:8.2.1553: crash in edit test

Problem:    Crash in edit test.
Solution:   Avoid using invalid pointer.
2c93c685e3
This commit is contained in:
James McCoy
2020-09-03 23:04:38 -04:00
parent 0c851e5226
commit ae8f108732

View File

@@ -573,31 +573,35 @@ void foldCreate(win_T *wp, linenr_T start, linenr_T end)
// Find the place to insert the new fold // Find the place to insert the new fold
gap = &wp->w_folds; gap = &wp->w_folds;
for (;; ) { if (gap->ga_len == 0) {
if (!foldFind(gap, start_rel, &fp)) i = 0;
break; } else {
if (fp->fd_top + fp->fd_len > end_rel) { for (;;) {
/* New fold is completely inside this fold: Go one level deeper. */ if (!foldFind(gap, start_rel, &fp))
gap = &fp->fd_nested; break;
start_rel -= fp->fd_top; if (fp->fd_top + fp->fd_len > end_rel) {
end_rel -= fp->fd_top; /* New fold is completely inside this fold: Go one level deeper. */
if (use_level || fp->fd_flags == FD_LEVEL) { gap = &fp->fd_nested;
use_level = true; start_rel -= fp->fd_top;
if (level >= wp->w_p_fdl) { end_rel -= fp->fd_top;
if (use_level || fp->fd_flags == FD_LEVEL) {
use_level = true;
if (level >= wp->w_p_fdl) {
closed = true;
}
} else if (fp->fd_flags == FD_CLOSED) {
closed = true; closed = true;
} }
} else if (fp->fd_flags == FD_CLOSED) { level++;
closed = true; } else {
/* This fold and new fold overlap: Insert here and move some folds
* inside the new fold. */
break;
} }
level++;
} else {
/* This fold and new fold overlap: Insert here and move some folds
* inside the new fold. */
break;
} }
i = (int)(fp - (fold_T *)gap->ga_data);
} }
i = (int)(fp - (fold_T *)gap->ga_data);
ga_grow(gap, 1); ga_grow(gap, 1);
{ {
fp = (fold_T *)gap->ga_data + i; fp = (fold_T *)gap->ga_data + i;