diff options
author | nwounkn <nwounkn@gmail.com> | 2023-08-29 13:48:23 +0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-29 10:48:23 +0200 |
commit | 6e45567b498ca8455aaf3628c10de997ac070ee1 (patch) | |
tree | 7a06cda229211cc7890607287ab5b2c3b1b888b8 /test/functional/treesitter/node_spec.lua | |
parent | 97badc9ac41e0c90d6e4a4389c3b7c022a5dfb88 (diff) | |
download | rneovim-6e45567b498ca8455aaf3628c10de997ac070ee1.tar.gz rneovim-6e45567b498ca8455aaf3628c10de997ac070ee1.tar.bz2 rneovim-6e45567b498ca8455aaf3628c10de997ac070ee1.zip |
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.
Diffstat (limited to 'test/functional/treesitter/node_spec.lua')
-rw-r--r-- | test/functional/treesitter/node_spec.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/functional/treesitter/node_spec.lua b/test/functional/treesitter/node_spec.lua index 5ff73d3a8d..72508ba958 100644 --- a/test/functional/treesitter/node_spec.lua +++ b/test/functional/treesitter/node_spec.lua @@ -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) { |