Patch 8.2.3611
Problem:    Crash when using CTRL-W f without finding a file name.
Solution:   Bail out when the file name length is zero.
Files:      src/findfile.c, src/normal.c, src/testdir/test_visual.vim


*** ../vim-8.2.3610/src/findfile.c      2021-07-27 21:00:39.745712396 +0100
--- src/findfile.c      2021-11-17 17:58:23.485079529 +0000
***************
*** 1735,1740 ****
--- 1735,1743 ----
      proc->pr_WindowPtr = (APTR)-1L;
  # endif
  
+     if (len == 0)
+       return NULL;
+ 
      if (first == TRUE)
      {
        // copy file name into NameBuff, expanding environment variables
***************
*** 2118,2124 ****
--- 2121,2132 ----
      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);
*** ../vim-8.2.3610/src/normal.c        2021-11-17 16:52:36.786672588 +0000
--- src/normal.c        2021-11-17 17:53:17.857207303 +0000
***************
*** 3881,3888 ****
            *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.
            *lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;
      }
      reset_VIsual_and_resel();
--- 3881,3890 ----
            *pp = ml_get_pos(&VIsual);
            *lenp = curwin->w_cursor.col - VIsual.col + 1;
        }
!       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();
*** ../vim-8.2.3610/src/testdir/test_visual.vim 2021-10-11 15:40:36.476538476 
+0100
--- src/testdir/test_visual.vim 2021-11-17 17:59:20.409049130 +0000
***************
*** 1265,1270 ****
--- 1265,1278 ----
    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
*** ../vim-8.2.3610/src/version.c       2021-11-17 16:52:36.786672588 +0000
--- src/version.c       2021-11-17 17:23:35.228661340 +0000
***************
*** 759,760 ****
--- 759,762 ----
  {   /* Add new patch number below this line */
+ /**/
+     3611,
  /**/

-- 
The early bird gets the worm. If you want something else for
breakfast, get up later.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211117180059.026741C656C%40moolenaar.net.

Raspunde prin e-mail lui