mirror of
https://github.com/neovim/neovim.git
synced 2025-11-17 07:41:27 +00:00
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.
8ecfa2c56b
Nvim already copies the mark.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user