diff --git a/src/output-lua.c b/src/output-lua.c index aedb0031d5cf..3d083e57d359 100644 --- a/src/output-lua.c +++ b/src/output-lua.c @@ -647,8 +647,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 bc0c20c88715..f03216f85ad2 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