mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 06:58:35 +00:00
fix(treesitter): fix TSNode:tree() double free (#24796)
Problem: `push_tree`, every time its called for the same TSTree with `do_copy=false` argument, creates a new userdata for it. Each userdata, when garbage collected, frees the same TSTree C object. Solution: Add flag to userdata, which indicates, should C object, which userdata points to, be freed, when userdata is garbage collected.
This commit is contained in:

committed by
Christian Clason

parent
e3389c1533
commit
a3c963adfc
@@ -4,6 +4,7 @@ local clear = helpers.clear
|
||||
local eq = helpers.eq
|
||||
local exec_lua = helpers.exec_lua
|
||||
local insert = helpers.insert
|
||||
local assert_alive = helpers.assert_alive
|
||||
|
||||
before_each(clear)
|
||||
|
||||
@@ -14,6 +15,17 @@ end
|
||||
describe('treesitter node API', function()
|
||||
clear()
|
||||
|
||||
it('double free tree', function()
|
||||
insert('F')
|
||||
exec_lua([[
|
||||
vim.treesitter.start(0, 'lua')
|
||||
vim.treesitter.get_node():tree()
|
||||
vim.treesitter.get_node():tree()
|
||||
collectgarbage()
|
||||
]])
|
||||
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