]> granicus.if.org Git - vim/commitdiff
patch 8.2.3471: crash when using CTRL-T after an empty search pattern v8.2.3471
authorBram Moolenaar <Bram@vim.org>
Mon, 4 Oct 2021 18:47:35 +0000 (19:47 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 4 Oct 2021 18:47:35 +0000 (19:47 +0100)
Problem:    Crash when using CTRL-T after an empty search pattern.
Solution:   Bail out when there is no previous search pattern. (closes #8953)

src/ex_getln.c
src/testdir/test_search.vim
src/version.c

index a49fa05eb83e936813b9caad8b38534785de521c..07eac908635936f7c824d76f56531b01167870ff 100644 (file)
@@ -612,7 +612,8 @@ may_adjust_incsearch_highlighting(
     // NOTE: must call restore_last_search_pattern() before returning!
     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();
        return OK;
@@ -626,6 +627,11 @@ may_adjust_incsearch_highlighting(
     if (search_delim == ccline.cmdbuff[skiplen])
     {
        pat = last_search_pattern();
+       if (pat == NULL)
+       {
+           restore_last_search_pattern();
+           return FAIL;
+       }
        skiplen = 0;
        patlen = (int)STRLEN(pat);
     }
index dd47f4f4e48cd635cccd7526493e25d7af1baee4..bc2b3ad7bf4e3b8e220d6394ab95d189530b9691 100644 (file)
@@ -1977,4 +1977,14 @@ func Test_pattern_is_uppercase_smartcase()
   bw!
 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
index 23b0c3682c7e18c2d65379ad11fc10cbdd5ba14d..b540523b494b05c8b9c830e08bda184102e2c86e 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3471,
 /**/
     3470,
 /**/