diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-08-29 11:21:57 +0200 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-08-29 11:35:46 +0200 |
commit | 50a03c0e9975925e3198a2741c5b9fc0ad727e84 (patch) | |
tree | 60af1e770fe2ada5a4089318377264c80886dedd /test/functional/treesitter/node_spec.lua | |
parent | 6e45567b498ca8455aaf3628c10de997ac070ee1 (diff) | |
download | rneovim-50a03c0e9975925e3198a2741c5b9fc0ad727e84.tar.gz rneovim-50a03c0e9975925e3198a2741c5b9fc0ad727e84.tar.bz2 rneovim-50a03c0e9975925e3198a2741c5b9fc0ad727e84.zip |
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)
Diffstat (limited to 'test/functional/treesitter/node_spec.lua')
-rw-r--r-- | test/functional/treesitter/node_spec.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/functional/treesitter/node_spec.lua b/test/functional/treesitter/node_spec.lua index 72508ba958..eef75d0e91 100644 --- a/test/functional/treesitter/node_spec.lua +++ b/test/functional/treesitter/node_spec.lua @@ -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) { |