0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

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 #8953)
This commit is contained in:
Bram Moolenaar 2021-10-04 19:47:35 +01:00
parent a684a68409
commit d8d957de86
3 changed files with 19 additions and 1 deletions

View File

@ -612,7 +612,8 @@ may_adjust_incsearch_highlighting(
// NOTE: must call restore_last_search_pattern() before returning! // NOTE: must call restore_last_search_pattern() before returning!
save_last_search_pattern(); save_last_search_pattern();
if (!do_incsearch_highlighting(firstc, &search_delim, is_state, &skiplen, &patlen)) if (!do_incsearch_highlighting(firstc, &search_delim, is_state,
&skiplen, &patlen))
{ {
restore_last_search_pattern(); restore_last_search_pattern();
return OK; return OK;
@ -626,6 +627,11 @@ may_adjust_incsearch_highlighting(
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);
} }

View File

@ -1977,4 +1977,14 @@ func Test_pattern_is_uppercase_smartcase()
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

View File

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