mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 23:18:33 +00:00
fix(api): fix crash in command preview with % #35228
Problem: parse_cmdline() sets eap->cmdlinep to address of local parameter, causing invalid memory access when expand_filename() tries to modify it. This leads to crashes when typing '%' in user commands with preview=true and complete=file. Solution: Change parse_cmdline() signature to accept char **cmdline, allowing cmdlinep to point to caller's variable for safe reallocation.
This commit is contained in:
@@ -615,6 +615,25 @@ describe("'inccommand' for user commands", function()
|
||||
:Repro abc^ |
|
||||
]])
|
||||
end)
|
||||
|
||||
it('no crash with % + preview + file completion #28851', function()
|
||||
exec_lua([[
|
||||
local function callback() end
|
||||
local function preview()
|
||||
return 0
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('TestCommand', callback, {
|
||||
nargs = '?',
|
||||
complete = 'file',
|
||||
preview = preview,
|
||||
})
|
||||
|
||||
vim.cmd.edit('Xtestscript')
|
||||
]])
|
||||
feed(':TestCommand %')
|
||||
assert_alive()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("'inccommand' with multiple buffers", function()
|
||||
|
Reference in New Issue
Block a user