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.

0ff01835a4

Cherry-pick a cmdwin change from patch 9.0.0500.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-08-22 22:48:55 +08:00
committed by GitHub
parent e34eb4ccf9
commit b84a67f50e
7 changed files with 48 additions and 12 deletions

View File

@@ -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) {