diff options
| author | neovim-backports[bot] <175700243+neovim-backports[bot]@users.noreply.github.com> | 2026-04-24 17:27:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-24 17:27:46 -0400 |
| commit | e5d6d2e769cc28fa7fa3e1d7e08e997282acd082 (patch) | |
| tree | 56e23d702faaa5850e082cf89f7abf01b5c7788c /runtime/lua/vim/lsp/client.lua | |
| parent | 4df16ecdb9d4686dd30e02d8b3c0653dc11c48ab (diff) | |
backport: fix(api): leak `preview` callback `LuaRef` in `nvim_create_user_command` (#39377)
Problem:
Invalid `nvim_create_user_command` calls can leak the
`preview` callback reference after Neovim has taken ownership of it.
1. build with {a,l}san
2. run:
```sh
<path/to/nvim> --headless -u NONE --clean +'lua
for i = 1, 100 do
pcall(vim.api.nvim_create_user_command,
"some very epic stuff" .. i,
{}, -- NOTE: this is INVALID (not a function or string)
{ preview = function() end })
end
vim.cmd("qa!")
' +qa
```
3. see:
```
100 lua references were leaked!
```
Solution:
Clear `preview_luaref` in `err:`.
(cherry picked from commit 393f687503a319a6f521e8335b4dd8030e3ea67b)
Co-authored-by: Barrett Ruth <62671086+barrettruth@users.noreply.github.com>
Diffstat (limited to 'runtime/lua/vim/lsp/client.lua')
0 files changed, 0 insertions, 0 deletions
