diff --git a/src/hlua.c b/src/hlua.c index 96773a86a..eab77324c 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -1811,10 +1811,15 @@ static int hlua_ctx_renew(struct hlua *lua, int keep_msg) lua_State *T; int new_ref; + if (!SET_SAFE_LJMP_PARENT(lua)) + return 0; + /* New Lua coroutine. */ T = lua_newthread(hlua_states[lua->state_id]); - if (!T) + if (!T) { + RESET_SAFE_LJMP_PARENT(lua); return 0; + } /* Copy last error message. */ if (keep_msg) @@ -1836,6 +1841,8 @@ static int hlua_ctx_renew(struct hlua *lua, int keep_msg) lua->T = T; lua->Tref = luaL_ref(hlua_states[lua->state_id], LUA_REGISTRYINDEX); + RESET_SAFE_LJMP_PARENT(lua); + /* Set context. */ hlua_sethlua(lua);