0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

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 #6968)
This commit is contained in:
Bram Moolenaar
2020-09-17 19:36:04 +02:00
parent 08e51f446b
commit da697645d5
3 changed files with 23 additions and 2 deletions

View File

@@ -2422,8 +2422,8 @@ foldUpdateIEMSRecurse(
&& 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

@@ -816,4 +816,23 @@ func Test_fold_expr_error()
close!
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([''])
set fdm&vim
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1702,
/**/
1701,
/**/