summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_defaults.lua
diff options
context:
space:
mode:
authorRodrigodd <rodrigobatsmoraes@hotmail.com>2025-06-03 21:53:58 -0300
committerLewis Russell <me@lewisr.dev>2025-06-06 15:35:52 +0100
commit99e629481943929cbaa05bbf3e08e03e9a768fae (patch)
tree7c194a6170c0c1a26f9ef652f2f5c5085ed92a6e /runtime/lua/vim/_defaults.lua
parentcb036cae5fb1ab0fb699436d2dbbc3295657967e (diff)
fix(treesitter): ensure TSNode's tree is immutable
Problem: TSNode contains a `const TSTree*` and a `const void *id`. The `id` points to Tree-sitter's internal type `Subtree`, which resides inside the `TSTree` but may be deallocated if the `TSTree` is mutated (which is likely why it is `const`). The Lua method `TSTree:edit()` mutates the tree, which can deallocate `id`. See #25254 and #31758. Solution: To avoid this, we now make a copy of the tree before pushing its root to the Lua stack. This also removes the fenv from TSLuaTree, as it was only used when pushing the tree root to the Lua stack. We also copy the tree in `node_tree`. `ts_tree_copy()` just increments a couple of reference counters, so it's relatively cheap to call.
Diffstat (limited to 'runtime/lua/vim/_defaults.lua')
0 files changed, 0 insertions, 0 deletions