mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 10:01:49 +00:00
fix(autocmd): heap UAF with :bwipe in Syntax autocmd
Problem: Creating an autocommand which executes `:bwipe` on the Syntax event causes a heap-use-after-free. Solution: set BF_SYN_SET flag before applying autocommands
This commit is contained in:
committed by
Sean Dewar
parent
5a65321684
commit
f36dd7557a
@@ -2715,11 +2715,11 @@ static void do_syntax_autocmd(buf_T *buf, bool value_changed)
|
|||||||
static int syn_recursive = 0;
|
static int syn_recursive = 0;
|
||||||
|
|
||||||
syn_recursive++;
|
syn_recursive++;
|
||||||
|
buf->b_flags |= BF_SYN_SET;
|
||||||
// Only pass true for "force" when the value changed or not used
|
// Only pass true for "force" when the value changed or not used
|
||||||
// recursively, to avoid endless recurrence.
|
// recursively, to avoid endless recurrence.
|
||||||
apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, buf->b_fname,
|
apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, buf->b_fname,
|
||||||
value_changed || syn_recursive == 1, buf);
|
value_changed || syn_recursive == 1, buf);
|
||||||
buf->b_flags |= BF_SYN_SET;
|
|
||||||
syn_recursive--;
|
syn_recursive--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -716,6 +716,15 @@ describe('autocmd', function()
|
|||||||
]]
|
]]
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('no use-after-free when wiping buffer in Syntax autocommand', function()
|
||||||
|
exec([[
|
||||||
|
new
|
||||||
|
autocmd Syntax * ++once bwipe!
|
||||||
|
setlocal syntax=vim
|
||||||
|
]])
|
||||||
|
assert_alive()
|
||||||
|
end)
|
||||||
|
|
||||||
it('no use-after-free from win_enter autocommands in win_move_after', function()
|
it('no use-after-free from win_enter autocommands in win_move_after', function()
|
||||||
exec [[
|
exec [[
|
||||||
split foo
|
split foo
|
||||||
|
|||||||
Reference in New Issue
Block a user