mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
25513049b3
commit
2000e1621d
@ -651,6 +651,10 @@ int searchit(
|
|||||||
colnr_T col = at_first_line && (options & SEARCH_COL) ? pos->col : 0;
|
colnr_T col = at_first_line && (options & SEARCH_COL) ? pos->col : 0;
|
||||||
nmatched = vim_regexec_multi(®match, win, buf,
|
nmatched = vim_regexec_multi(®match, win, buf,
|
||||||
lnum, col, tm, timed_out);
|
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).
|
// Abort searching on an error (e.g., out of stack).
|
||||||
if (called_emsg || (timed_out != NULL && *timed_out)) {
|
if (called_emsg || (timed_out != NULL && *timed_out)) {
|
||||||
break;
|
break;
|
||||||
@ -722,6 +726,10 @@ int searchit(
|
|||||||
match_ok = false;
|
match_ok = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// vim_regexec_multi() may clear "regprog"
|
||||||
|
if (regmatch.regprog == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
matchpos = regmatch.startpos[0];
|
matchpos = regmatch.startpos[0];
|
||||||
endpos = regmatch.endpos[0];
|
endpos = regmatch.endpos[0];
|
||||||
submatch = first_submatch(®match);
|
submatch = first_submatch(®match);
|
||||||
@ -811,10 +819,13 @@ int searchit(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// vim_regexec_multi() may clear "regprog"
|
||||||
/* Need to get the line pointer again, a
|
if (regmatch.regprog == NULL) {
|
||||||
* multi-line search may have made it invalid. */
|
break;
|
||||||
ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
|
}
|
||||||
|
// 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;
|
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
|
// Stop the search if wrapscan isn't set, "stop_lnum" is
|
||||||
// specified, after an interrupt, after a match and after looping
|
// specified, after an interrupt, after a match and after looping
|
||||||
// twice.
|
// twice.
|
||||||
@ -4243,7 +4259,8 @@ is_zero_width(char_u *pattern, int move, pos_T *cur, Direction direction)
|
|||||||
if (nmatched != 0) {
|
if (nmatched != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (direction == FORWARD
|
} while (regmatch.regprog != NULL
|
||||||
|
&& direction == FORWARD
|
||||||
? regmatch.startpos[0].col < pos.col
|
? regmatch.startpos[0].col < pos.col
|
||||||
: regmatch.startpos[0].col > pos.col);
|
: regmatch.startpos[0].col > pos.col);
|
||||||
|
|
||||||
|
@ -981,6 +981,21 @@ func Test_incsearch_substitute()
|
|||||||
call Incsearch_cleanup()
|
call Incsearch_cleanup()
|
||||||
endfunc
|
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()
|
func Test_search_undefined_behaviour()
|
||||||
if !has("terminal")
|
if !has("terminal")
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user