vim-patch:8.2.1702: crash when using undo after deleting folded lines

Problem:    Crash when using undo after deleting folded lines.
Solution:   Check for NULL pointer. (closes vim/vim#6968)
da697645d5
This commit is contained in:
Jan Edmund Lazo 2021-06-10 08:27:18 -04:00
parent 292037ef9b
commit cb368e1bff
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 23 additions and 2 deletions

View File

@ -2227,8 +2227,9 @@ static linenr_T foldUpdateIEMSRecurse(
if (getlevel == foldlevelMarker && flp->start <= flp->lvl - level
&& flp->lvl > 0) {
(void)foldFind(gap, startlnum - 1, &fp);
if (fp >= ((fold_T *)gap->ga_data) + gap->ga_len
|| fp->fd_top >= startlnum) {
if (fp != NULL
&& (fp >= ((fold_T *)gap->ga_data) + gap->ga_len
|| fp->fd_top >= startlnum)) {
fp = NULL;
}
}

View File

@ -796,6 +796,26 @@ func Test_fold_delete_first_line()
set foldmethod&
endfunc
func Test_undo_fold_deletion()
new
set fdm=marker
let lines =<< trim END
" {{{
" }}}1
" {{{
END
call setline(1, lines)
3d
g/"/d
undo
redo
" eval getline(1, '$')->assert_equal([''])
eval assert_equal(getline(1, '$'), [''])
set fdm&vim
bwipe!
endfunc
" this was crashing
func Test_move_no_folds()
new