summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-11-17 18:00:31 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-17 18:00:31 +0000
commit615ddd5342b50a6878a907062aa471740bd9a847 (patch)
treecfd9016b076095fb8c4aa4b1abace4eb0fcc1578 /src
parenta062006b9de0b2947ab5fb376c6e67ef92a8cd69 (diff)
patch 8.2.3611: crash when using CTRL-W f without finding a file namev8.2.3611
Problem: Crash when using CTRL-W f without finding a file name. Solution: Bail out when the file name length is zero.
Diffstat (limited to 'src')
-rw-r--r--src/findfile.c8
-rw-r--r--src/normal.c6
-rw-r--r--src/testdir/test_visual.vim8
-rw-r--r--src/version.c2
4 files changed, 22 insertions, 2 deletions
diff --git a/src/findfile.c b/src/findfile.c
index b79b1d1dbf..b4aed048ce 100644
--- a/src/findfile.c
+++ b/src/findfile.c
@@ -1735,6 +1735,9 @@ find_file_in_path_option(
proc->pr_WindowPtr = (APTR)-1L;
# endif
+ if (len == 0)
+ return NULL;
+
if (first == TRUE)
{
// copy file name into NameBuff, expanding environment variables
@@ -2118,7 +2121,12 @@ find_file_name_in_path(
int c;
# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
char_u *tofree = NULL;
+# endif
+ if (len == 0)
+ return NULL;
+
+# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL)
{
tofree = eval_includeexpr(ptr, len);
diff --git a/src/normal.c b/src/normal.c
index 059baee90f..aab336a5fe 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -3881,8 +3881,10 @@ get_visual_text(
*pp = ml_get_pos(&VIsual);
*lenp = curwin->w_cursor.col - VIsual.col + 1;
}
- if (has_mbyte)
- // Correct the length to include the whole last character.
+ if (**pp == NUL)
+ *lenp = 0;
+ if (has_mbyte && *lenp > 0)
+ // Correct the length to include all bytes of the last character.
*lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;
}
reset_VIsual_and_resel();
diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim
index 20eb4b43e8..0c89dbb010 100644
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -1265,6 +1265,14 @@ func Test_visual_block_with_virtualedit()
call delete('XTest_block')
endfunc
+func Test_visual_block_ctrl_w_f()
+ " Emtpy block selected in new buffer should not result in an error.
+ au! BufNew foo sil norm f
+ edit foo
+
+ au! BufNew
+endfunc
+
func Test_visual_reselect_with_count()
" this was causing an illegal memory access
let lines =<< trim END
diff --git a/src/version.c b/src/version.c
index d301120079..4251b03ea5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3611,
+/**/
3610,
/**/
3609,