aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mark.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-13 10:47:39 +0800
committerGitHub <noreply@github.com>2022-12-13 10:47:39 +0800
commita6b05cb75d330dd995d3ad21ee08bb0a2cfcae74 (patch)
tree6352994679c5a6c9d1afc18476acfd17f9187b59 /src/nvim/mark.c
parent0b20762c6042f2bfc5facf05754fd549b95b3cc1 (diff)
downloadrneovim-a6b05cb75d330dd995d3ad21ee08bb0a2cfcae74.tar.gz
rneovim-a6b05cb75d330dd995d3ad21ee08bb0a2cfcae74.tar.bz2
rneovim-a6b05cb75d330dd995d3ad21ee08bb0a2cfcae74.zip
vim-patch:9.0.0530: using freed memory when autocmd changes mark (#21396)
Problem: Using freed memory when autocmd changes mark. Solution: Copy the mark before editing another buffer. https://github.com/vim/vim/commit/8ecfa2c56b4992c7f067b92488aa9acea5a454ad Nvim already copies the mark. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/mark.c')
-rw-r--r--src/nvim/mark.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index ad325ae057..c38aa834bf 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -551,6 +551,7 @@ MarkMoveRes mark_move_to(fmark_T *fm, MarkMove flags)
// Need to change buffer
fm_copy = *fm; // Copy, autocommand may change it
fm = &fm_copy;
+ // Jump to the file with the mark
res |= switch_to_mark_buf(fm, !(flags & kMarkJumpList));
// Failed switching buffer
if (res & kMarkMoveFailed) {
@@ -568,6 +569,7 @@ MarkMoveRes mark_move_to(fmark_T *fm, MarkMove flags)
// Move the cursor while keeping track of what changed for the caller
pos_T prev_pos = curwin->w_cursor;
pos_T pos = fm->mark;
+ // Set lnum again, autocommands my have changed it
curwin->w_cursor = fm->mark;
if (flags & kMarkBeginLine) {
beginline(BL_WHITE | BL_FIX);