diff options
author | virchau13 <virchau13@hexular.net> | 2021-10-08 12:31:24 +0800 |
---|---|---|
committer | virchau13 <virchau13@hexular.net> | 2021-10-08 18:22:33 +0800 |
commit | 6064376f6d06067e6e633e1e16312d143e53b500 (patch) | |
tree | 2a4c77b129cd97cf03b61793285ea9d300cb618a | |
parent | 7f93b2ab01c93720820712a3c81462a58d04dfa0 (diff) | |
download | rneovim-6064376f6d06067e6e633e1e16312d143e53b500.tar.gz rneovim-6064376f6d06067e6e633e1e16312d143e53b500.tar.bz2 rneovim-6064376f6d06067e6e633e1e16312d143e53b500.zip |
fix(api): check type in nlua_pop_keydict (#15940)
-rw-r--r-- | src/nvim/lua/converter.c | 6 | ||||
-rw-r--r-- | test/functional/lua/api_spec.lua | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index fd4cfc4c31..ca3c4f604a 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -1303,6 +1303,12 @@ void nlua_init_types(lua_State *const lstate) void nlua_pop_keydict(lua_State *L, void *retval, field_hash hashy, Error *err) { + if (!lua_istable(L, -1)) { + api_set_error(err, kErrorTypeValidation, "Expected lua table"); + lua_pop(L, -1); + return; + } + lua_pushnil(L); // [dict, nil] while (lua_next(L, -2)) { // [dict, key, value] diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua index fdf79d55b2..8551c3d2a0 100644 --- a/test/functional/lua/api_spec.lua +++ b/test/functional/lua/api_spec.lua @@ -194,6 +194,10 @@ describe('luaeval(vim.api.…)', function() exc_exec([[call luaeval("vim.api.nvim__id_dictionary(1)")]])) eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type', exc_exec([[call luaeval("vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.array})")]])) + + eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table', + exc_exec([[call luaeval("vim.api.nvim_set_keymap('', '', '', '')")]])) + -- TODO: check for errors with Tabpage argument -- TODO: check for errors with Window argument -- TODO: check for errors with Buffer argument |