From b3169380ad9f9f2054f1b19f21bf03793668b967 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 1 Apr 2018 08:29:11 +0300 Subject: [PATCH] Fix Lua state usage after closing it in sb_lua_close_state(). --- src/sb_lua.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sb_lua.c b/src/sb_lua.c index 3332fd70e..1babcb8ac 100644 --- a/src/sb_lua.c +++ b/src/sb_lua.c @@ -828,9 +828,6 @@ int sb_lua_close_state(lua_State *state) { sb_lua_ctxt_t * const ctxt = &tls_lua_ctxt; - if (state != NULL) - lua_close(state); - if (ctxt != NULL) { sb_lua_db_disconnect(state); @@ -842,6 +839,9 @@ int sb_lua_close_state(lua_State *state) } } + if (state != NULL) + lua_close(state); + ctxt->L = NULL; return 0;