aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2023-11-13 13:39:04 -0600
committerGregory Anders <greg@gpanders.com>2023-11-13 19:04:47 -0600
commit22eb2ba18336df6cd70a88f666818ee5d8ba92d2 (patch)
tree00c372c9e8be2d7e43dbe0eb997b4f2bbdc664cf /src
parente7c46438ab118c138a7370a9976e45854c356a89 (diff)
downloadrneovim-22eb2ba18336df6cd70a88f666818ee5d8ba92d2.tar.gz
rneovim-22eb2ba18336df6cd70a88f666818ee5d8ba92d2.tar.bz2
rneovim-22eb2ba18336df6cd70a88f666818ee5d8ba92d2.zip
fix(lua): do not schedule events if Nvim is exiting
If Nvim is in the process of exiting then we do not want to allocate any new refs onto the event loop, because they will not be freed and will result in a memory leak.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/lua/executor.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 716fe5e481..aed96a539a 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -366,6 +366,12 @@ static void nlua_schedule_event(void **argv)
static int nlua_schedule(lua_State *const lstate)
FUNC_ATTR_NONNULL_ALL
{
+ // If Nvim is exiting don't schedule tasks to run in the future. Any refs
+ // allocated here will not be cleaned up otherwise
+ if (exiting) {
+ return 0;
+ }
+
if (lua_type(lstate, 1) != LUA_TFUNCTION) {
lua_pushliteral(lstate, "vim.schedule: expected function");
return lua_error(lstate);