vim-patch:8.2.1787: crash with 'incsearch' and very long line

Problem:    Crash with 'incsearch' and very long line.
Solution:   Check whether regprog becomes NULL. (closes vim/vim#7063)
795aaa1e84

N/A patches for version.c:

vim-patch:8.2.1784: commits are not scanned for security problems

Problem:    commits are not scanned for security problems
Solution:   Enable Github code scanning. (Christian Brabandt, closes vim/vim#7057)
fa79be6b10
This commit is contained in:
Jan Edmund Lazo 2020-10-02 22:46:54 -04:00
parent 25513049b3
commit 2000e1621d
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 37 additions and 5 deletions

View File

@ -651,6 +651,10 @@ int searchit(
colnr_T col = at_first_line && (options & SEARCH_COL) ? pos->col : 0;
nmatched = vim_regexec_multi(&regmatch, win, buf,
lnum, col, tm, timed_out);
// vim_regexec_multi() may clear "regprog"
if (regmatch.regprog == NULL) {
break;
}
// Abort searching on an error (e.g., out of stack).
if (called_emsg || (timed_out != NULL && *timed_out)) {
break;
@ -722,6 +726,10 @@ int searchit(
match_ok = false;
break;
}
// vim_regexec_multi() may clear "regprog"
if (regmatch.regprog == NULL) {
break;
}
matchpos = regmatch.startpos[0];
endpos = regmatch.endpos[0];
submatch = first_submatch(&regmatch);
@ -811,10 +819,13 @@ int searchit(
}
break;
}
/* Need to get the line pointer again, a
* multi-line search may have made it invalid. */
ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
// vim_regexec_multi() may clear "regprog"
if (regmatch.regprog == NULL) {
break;
}
// Need to get the line pointer again, a
// multi-line search may have made it invalid.
ptr = ml_get_buf(buf, lnum + matchpos.lnum, false);
}
/*
@ -891,6 +902,11 @@ int searchit(
}
at_first_line = FALSE;
// vim_regexec_multi() may clear "regprog"
if (regmatch.regprog == NULL) {
break;
}
// Stop the search if wrapscan isn't set, "stop_lnum" is
// specified, after an interrupt, after a match and after looping
// twice.
@ -4243,7 +4259,8 @@ is_zero_width(char_u *pattern, int move, pos_T *cur, Direction direction)
if (nmatched != 0) {
break;
}
} while (direction == FORWARD
} while (regmatch.regprog != NULL
&& direction == FORWARD
? regmatch.startpos[0].col < pos.col
: regmatch.startpos[0].col > pos.col);

View File

@ -981,6 +981,21 @@ func Test_incsearch_substitute()
call Incsearch_cleanup()
endfunc
func Test_incsearch_substitute_long_line()
throw 'skipped: Nvim does not support test_override()'
new
call test_override("char_avail", 1)
set incsearch
call repeat('x', 100000)->setline(1)
call feedkeys(':s/\%c', 'xt')
redraw
call feedkeys("\<Esc>", 'xt')
call Incsearch_cleanup()
bwipe!
endfunc
func Test_search_undefined_behaviour()
if !has("terminal")
return