diff src/ex_getln.c @ 25874:054623fc54c5 v8.2.3471

patch 8.2.3471: crash when using CTRL-T after an empty search pattern Commit: https://github.com/vim/vim/commit/d8d957de86f218de9124ca1209548f8c6f61b69b Author: Bram Moolenaar <Bram@vim.org> Date: Mon Oct 4 19:47:35 2021 +0100 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 https://github.com/vim/vim/issues/8953)
author Bram Moolenaar <Bram@vim.org>
date Mon, 04 Oct 2021 21:00:06 +0200
parents 16a7d1154be8
children e8873138ffbb
line wrap: on
line diff
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -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);
     }