mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 9.0.0530: using freed memory when autocmd changes mark
Problem: Using freed memory when autocmd changes mark. Solution: Copy the mark before editing another buffer.
This commit is contained in:
12
src/mark.c
12
src/mark.c
@@ -221,17 +221,19 @@ movemark(int count)
|
|||||||
fname2fnum(jmp);
|
fname2fnum(jmp);
|
||||||
if (jmp->fmark.fnum != curbuf->b_fnum)
|
if (jmp->fmark.fnum != curbuf->b_fnum)
|
||||||
{
|
{
|
||||||
// jump to other file
|
// Make a copy, an autocommand may make "jmp" invalid.
|
||||||
if (buflist_findnr(jmp->fmark.fnum) == NULL)
|
fmark_T fmark = jmp->fmark;
|
||||||
|
|
||||||
|
// jump to the file with the mark
|
||||||
|
if (buflist_findnr(fmark.fnum) == NULL)
|
||||||
{ // Skip this one ..
|
{ // Skip this one ..
|
||||||
count += count < 0 ? -1 : 1;
|
count += count < 0 ? -1 : 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (buflist_getfile(jmp->fmark.fnum, jmp->fmark.mark.lnum,
|
if (buflist_getfile(fmark.fnum, fmark.mark.lnum, 0, FALSE) == FAIL)
|
||||||
0, FALSE) == FAIL)
|
|
||||||
return (pos_T *)NULL;
|
return (pos_T *)NULL;
|
||||||
// Set lnum again, autocommands my have changed it
|
// Set lnum again, autocommands my have changed it
|
||||||
curwin->w_cursor = jmp->fmark.mark;
|
curwin->w_cursor = fmark.mark;
|
||||||
pos = (pos_T *)-1;
|
pos = (pos_T *)-1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -305,4 +305,17 @@ func Test_getmarklist()
|
|||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This was using freed memory
|
||||||
|
func Test_jump_mark_autocmd()
|
||||||
|
next 00
|
||||||
|
edit 0
|
||||||
|
sargument
|
||||||
|
au BufEnter 0 all
|
||||||
|
sil norm
|
||||||
|
|
||||||
|
au! BufEnter
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -699,6 +699,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
530,
|
||||||
/**/
|
/**/
|
||||||
529,
|
529,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user