diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2022-01-03 16:00:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-03 08:00:50 -0700 |
commit | 297ff97647a6a68188390ef7808762bb5a13baa1 (patch) | |
tree | 7ab8c6d4fe3bcfa6ad88e965c57c308065b3c9b5 /src | |
parent | 76435c0cfa8f39024a3b931276478b5007a1f421 (diff) | |
download | rneovim-297ff97647a6a68188390ef7808762bb5a13baa1.tar.gz rneovim-297ff97647a6a68188390ef7808762bb5a13baa1.tar.bz2 rneovim-297ff97647a6a68188390ef7808762bb5a13baa1.zip |
fix(lua): stricter type check when calling API function (#16745)
Solves #13651
Co-authored-by: Gregory Anders <greg@gpanders.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/lua/converter.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index b6792a5a97..8a702ddd60 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -1242,7 +1242,12 @@ LuaRef nlua_pop_LuaRef(lua_State *const lstate, Error *err) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT \ { \ type ret; \ - ret = (type)lua_tonumber(lstate, -1); \ + if (lua_type(lstate, -1) != LUA_TNUMBER) { \ + api_set_error(err, kErrorTypeValidation, "Expected Lua number"); \ + ret = (type)-1; \ + } else { \ + ret = (type)lua_tonumber(lstate, -1); \ + } \ lua_pop(lstate, 1); \ return ret; \ } |