summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/api
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2026-03-14 13:07:55 +0100
committerGitHub <noreply@github.com>2026-03-14 08:07:55 -0400
commit83037cf2185704a4b9a93c0883dc93226de86fdc (patch)
treeadd5249fe53827acb69c9dcccab289fffd1600ab /test/functional/api
parent929be7ee00ed94bfa5094f4c9eee4006c75518c1 (diff)
fix(messages): allocate message history kind string #38292
Problem: nvim_echo()->kind memory may be used after it is freed with :messages. Solution: Copy and free message kind string in message history.
Diffstat (limited to 'test/functional/api')
-rw-r--r--test/functional/api/vim_spec.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 5e36a63264..92a7c8af25 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -3887,6 +3887,15 @@ describe('API', function()
eq(4, api.nvim_echo({ { 'foo' } }, false, { id = 4 }))
eq(5, api.nvim_echo({ { 'foo' } }, false, {}))
end)
+
+ it('no use-after-free for custom kind with :messages #38289', function()
+ exec_lua(function()
+ vim.api.nvim_echo({ { 'a' } }, true, { kind = 'foo' })
+ vim.o.guicursor = '' -- pending mode update go brrr
+ vim.api.nvim__redraw({ flush = true }) -- ui_flush -> arena_mem_free go brrr
+ vim.cmd.messages()
+ end)
+ end)
end)
describe('nvim_open_term', function()