aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/normal.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-01-18 10:05:31 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-01-18 10:05:31 +0800
commitec39e1e421101d2573ca5f9003238adfcd45dcd1 (patch)
tree5c8a2f3b2a89d7ec13140d10998c742d28aa7820 /src/nvim/normal.c
parent0a65d821fcc3fe1cab52b4102f2a55b7aa89df03 (diff)
downloadrneovim-ec39e1e421101d2573ca5f9003238adfcd45dcd1.tar.gz
rneovim-ec39e1e421101d2573ca5f9003238adfcd45dcd1.tar.bz2
rneovim-ec39e1e421101d2573ca5f9003238adfcd45dcd1.zip
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. https://github.com/vim/vim/commit/615ddd5342b50a6878a907062aa471740bd9a847
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r--src/nvim/normal.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 418ba133bd..1f528ce98a 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -4472,8 +4472,13 @@ bool get_visual_text(cmdarg_T *cap, char_u **pp, size_t *lenp)
*pp = ml_get_pos(&VIsual);
*lenp = (size_t)curwin->w_cursor.col - (size_t)VIsual.col + 1;
}
- // Correct the length to include the whole last character.
- *lenp += (size_t)(utfc_ptr2len(*pp + (*lenp - 1)) - 1);
+ if (**pp == NUL) {
+ *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();
return true;