To: vim_dev@googlegroups.com Subject: Patch 8.2.3611 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///