mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.3611: crash when using CTRL-W f without finding a file name
Problem: Crash when using CTRL-W f without finding a file name.
Solution: Bail out when the file name length is zero.
615ddd5342
This commit is contained in:
parent
0a65d821fc
commit
ec39e1e421
@ -1433,6 +1433,10 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
|
|||||||
rel_fname = NULL;
|
rel_fname = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (first == TRUE) {
|
if (first == TRUE) {
|
||||||
// copy file name into NameBuff, expanding environment variables
|
// copy file name into NameBuff, expanding environment variables
|
||||||
save_char = ptr[len];
|
save_char = ptr[len];
|
||||||
|
@ -4472,8 +4472,13 @@ bool get_visual_text(cmdarg_T *cap, char_u **pp, size_t *lenp)
|
|||||||
*pp = ml_get_pos(&VIsual);
|
*pp = ml_get_pos(&VIsual);
|
||||||
*lenp = (size_t)curwin->w_cursor.col - (size_t)VIsual.col + 1;
|
*lenp = (size_t)curwin->w_cursor.col - (size_t)VIsual.col + 1;
|
||||||
}
|
}
|
||||||
// Correct the length to include the whole last character.
|
if (**pp == NUL) {
|
||||||
*lenp += (size_t)(utfc_ptr2len(*pp + (*lenp - 1)) - 1);
|
*lenp = 0;
|
||||||
|
}
|
||||||
|
if (*lenp > 0) {
|
||||||
|
// Correct the length to include all bytes of the last character.
|
||||||
|
*lenp += (size_t)(utfc_ptr2len(*pp + (*lenp - 1)) - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reset_VIsual_and_resel();
|
reset_VIsual_and_resel();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1682,6 +1682,10 @@ char_u *find_file_name_in_path(char_u *ptr, size_t len, int options, long count,
|
|||||||
char_u *file_name;
|
char_u *file_name;
|
||||||
char_u *tofree = NULL;
|
char_u *tofree = NULL;
|
||||||
|
|
||||||
|
if (len == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
|
if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
|
||||||
tofree = (char_u *)eval_includeexpr((char *)ptr, len);
|
tofree = (char_u *)eval_includeexpr((char *)ptr, len);
|
||||||
if (tofree != NULL) {
|
if (tofree != NULL) {
|
||||||
|
@ -1123,6 +1123,14 @@ func Test_visual_block_with_virtualedit()
|
|||||||
call delete('XTest_block')
|
call delete('XTest_block')
|
||||||
endfunc
|
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()
|
func Test_visual_reselect_with_count()
|
||||||
" this was causing an illegal memory access
|
" this was causing an illegal memory access
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
|
Loading…
Reference in New Issue
Block a user