fix(context): don't crash on invalid arg to nvim_get_context (#25977)

Note: The crash happens in the second test case when using uninitialized
memory, and therefore doesn't happen with ASAN.
This commit is contained in:
zeertzjq
2023-11-11 10:21:14 +08:00
committed by GitHub
parent d1b2a5cf5f
commit e9b9a86cd5
7 changed files with 45 additions and 18 deletions

View File

@@ -1979,6 +1979,13 @@ describe('API', function()
nvim('load_context', ctx)
eq({1, 2 ,3}, eval('[g:one, g:Two, g:THREE]'))
end)
it('errors when context dictionary is invalid', function()
eq('E474: Failed to convert list to msgpack string buffer',
pcall_err(nvim, 'load_context', { regs = { {} } }))
eq("Empty dictionary keys aren't allowed",
pcall_err(nvim, 'load_context', { regs = { { [''] = '' } } }))
end)
end)
describe('nvim_replace_termcodes', function()