vim-patch:8.2.3471: crash when using CTRL-T after an empty search pattern

Problem:    Crash when using CTRL-T after an empty search pattern.
Solution:   Bail out when there is no previous search pattern. (closes vim/vim#8953)
d8d957de86
This commit is contained in:
zeertzjq 2022-04-01 17:08:04 +08:00
parent 88a4ac22f0
commit 649a11bc13
2 changed files with 14 additions and 0 deletions

View File

@ -1606,6 +1606,10 @@ static int may_do_command_line_next_incsearch(int firstc, long count, incsearch_
if (search_delim == ccline.cmdbuff[skiplen]) { if (search_delim == ccline.cmdbuff[skiplen]) {
pat = last_search_pattern(); pat = last_search_pattern();
if (pat == NULL) {
restore_last_search_pattern();
return FAIL;
}
skiplen = 0; skiplen = 0;
patlen = (int)STRLEN(pat); patlen = (int)STRLEN(pat);
} else { } else {

View File

@ -1527,4 +1527,14 @@ func Test_incsearch_highlighting_newline()
bw bw
endfunc endfunc
func Test_no_last_search_pattern()
CheckOption incsearch
let @/ = ""
set incsearch
" this was causing a crash
call feedkeys("//\x14", 'xt')
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab