From aebc666efaf388f4e7a71243c4954f855e572248 Mon Sep 17 00:00:00 2001 From: nhkeni Date: Fri, 12 Jan 2024 11:06:25 -0500 Subject: [PATCH] clean up lua error message, catch failed lua_newstate call --- src/nhlua.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nhlua.c b/src/nhlua.c index c0c6ac554..08e422e4e 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -1928,7 +1928,7 @@ nhl_pcall_handle(lua_State *L, int nargs, int nresults, const char *name, /* XXX can we get a lua stack trace as well? */ switch(npa){ case NHLpa_panic: - panic("time exceeded %d:%s %s", nud->sid, + panic("Lua error %d:%s %s", nud->sid, nud->name?nud->name:"(unknown)", lua_tostring(L, -1)); case NHLpa_impossible: impossible("Lua error: %d:%s %s", nud->sid, @@ -2828,6 +2828,7 @@ nhlL_newstate(nhl_sandbox_info *sbi, const char *name) } lua_State *L = lua_newstate(nhl_alloc, nud); + if(!L)panic("NULL lua_newstate"); lua_atpanic(L, nhl_panic); #if LUA_VERSION_NUM == 504