aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-11-11 10:21:14 +0800
committerGitHub <noreply@github.com>2023-11-11 10:21:14 +0800
commite9b9a86cd5a555943b87f0ba40c4527561c3c124 (patch)
treeb1f2aef3e5e68053a8d2f08206b2c61083e6f6c1 /test/functional/api/vim_spec.lua
parentd1b2a5cf5fa583b556457d34a46ce7b940913a66 (diff)
downloadrneovim-e9b9a86cd5a555943b87f0ba40c4527561c3c124.tar.gz
rneovim-e9b9a86cd5a555943b87f0ba40c4527561c3c124.tar.bz2
rneovim-e9b9a86cd5a555943b87f0ba40c4527561c3c124.zip
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.
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index c346dfbe6c..bc7e747916 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -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()