From 35edc5264d62d20186c435826c224fbd674a4dc9 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 1 Jun 2017 23:49:28 +0200 Subject: [PATCH] luajit: cleanup states before return to pool --- src/output-lua.c | 2 -- src/util-lua.c | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/output-lua.c b/src/output-lua.c index 9c34c2648d..16f599aaf5 100644 --- a/src/output-lua.c +++ b/src/output-lua.c @@ -574,8 +574,6 @@ static int LuaScriptInit(const char *filename, LogLuaScriptOptions *options) { goto error; } - /* pop the table */ - lua_pop(luastate, 1); LuaReturnState(luastate); return 0; error: diff --git a/src/util-lua.c b/src/util-lua.c index bc0c20c887..f03216f85a 100644 --- a/src/util-lua.c +++ b/src/util-lua.c @@ -70,6 +70,10 @@ lua_State *LuaGetState(void) void LuaReturnState(lua_State *s) { if (s != NULL) { + /* clear the stack */ + while (lua_gettop(s) > 0) { + lua_pop(s, 1); + } #ifdef HAVE_LUAJIT LuajitReturnState(s); #else