mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 05:28:33 +00:00
fix(treesitter): fix another TSNode:tree() double free
Unfortunately the gc=false objects can refer to a dangling tree if the gc=true tree was freed first. This reuses the same tree object as the node itself is keeping alive via the uservalue of the node userdata. (wrapped in a table due to lua 5.1 restrictions)
This commit is contained in:
@@ -26,6 +26,20 @@ describe('treesitter node API', function()
|
||||
assert_alive()
|
||||
end)
|
||||
|
||||
it('double free tree 2', function()
|
||||
exec_lua([[
|
||||
parser = vim.treesitter.get_parser(0, "c")
|
||||
local x = parser:parse()[1]:root():tree()
|
||||
vim.api.nvim_buf_set_text(0, 0,0, 0,0, {'y'})
|
||||
parser:parse()
|
||||
vim.api.nvim_buf_set_text(0, 0,0, 0,1, {'z'})
|
||||
parser:parse()
|
||||
collectgarbage()
|
||||
x:root()
|
||||
]])
|
||||
assert_alive()
|
||||
end)
|
||||
|
||||
it('can move between siblings', function()
|
||||
insert([[
|
||||
int main(int x, int y, int z) {
|
||||
|
Reference in New Issue
Block a user