aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-22 22:48:55 +0800
committerGitHub <noreply@github.com>2023-08-22 22:48:55 +0800
commitb84a67f50ed6141f72d433094a1a611ae4f67924 (patch)
tree489d51091837a31218e6634910a81ff65e225b2d /src/nvim/ex_getln.c
parente34eb4ccf9c3a9c04127cb8e00742ed2e3316484 (diff)
downloadrneovim-b84a67f50ed6141f72d433094a1a611ae4f67924.tar.gz
rneovim-b84a67f50ed6141f72d433094a1a611ae4f67924.tar.bz2
rneovim-b84a67f50ed6141f72d433094a1a611ae4f67924.zip
vim-patch:9.0.0579: using freed memory when 'tagfunc' wipes out buffer (#24838)
Problem: Using freed memory when 'tagfunc' wipes out buffer that holds 'complete'. Solution: Make a copy of the option. Make sure cursor position is valid. https://github.com/vim/vim/commit/0ff01835a40f549c5c4a550502f62a2ac9ac447c Cherry-pick a cmdwin change from patch 9.0.0500. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r--src/nvim/ex_getln.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 6af79bfd21..c401293ccc 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -4572,7 +4572,8 @@ static int open_cmdwin(void)
ccline.cmdlen = (int)strlen(ccline.cmdbuff);
ccline.cmdbufflen = ccline.cmdlen + 1;
ccline.cmdpos = curwin->w_cursor.col;
- if (ccline.cmdpos > ccline.cmdlen) {
+ // If the cursor is on the last character, it probably should be after it.
+ if (ccline.cmdpos == ccline.cmdlen - 1 || ccline.cmdpos > ccline.cmdlen) {
ccline.cmdpos = ccline.cmdlen;
}
if (cmdwin_result == K_IGNORE) {