aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-12-12 20:34:02 +0800
committerGitHub <noreply@github.com>2023-12-12 20:34:02 +0800
commitb40170f7a3ca4bd157eeb52c9d57cb2ebfe3c562 (patch)
treef7f58e7e15ee0fbd887587c19f740179d807d1b0 /src/nvim/lua/executor.c
parent1d4a5cd18537d054a564ff19b9361120597d9dd7 (diff)
downloadrneovim-b40170f7a3ca4bd157eeb52c9d57cb2ebfe3c562.tar.gz
rneovim-b40170f7a3ca4bd157eeb52c9d57cb2ebfe3c562.tar.bz2
rneovim-b40170f7a3ca4bd157eeb52c9d57cb2ebfe3c562.zip
fix(lua): memory leak when using invalid syntax with exists() (#26530)
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r--src/nvim/lua/executor.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index e0bdbbc1e9..0763bbd329 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -2323,10 +2323,12 @@ bool nlua_func_exists(const char *lua_funcname)
vim_snprintf(str, length, "return %s", lua_funcname);
ADD_C(args, CSTR_AS_OBJ(str));
Error err = ERROR_INIT;
- Object result = NLUA_EXEC_STATIC("return type(loadstring(...)()) =='function'", args, &err);
+ Object result = NLUA_EXEC_STATIC("return type(loadstring(...)()) == 'function'", args, &err);
xfree(str);
+ api_clear_error(&err);
if (result.type != kObjectTypeBoolean) {
+ api_free_object(result);
return false;
}
return result.data.boolean;