From 9da3fe67273b84f972f322735b0631947fcbc660 Mon Sep 17 00:00:00 2001 From: jussi Date: Fri, 11 Nov 2022 21:15:10 +0200 Subject: Interpreter call lua file in safe mode. --- src/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 2e07e37..0f935a1 100644 --- a/src/main.c +++ b/src/main.c @@ -43,7 +43,17 @@ int main( int argn, const char **argc ) { if ( interpret_mode ) { stateInitInterpret(); - luaL_dofile( state->luaState, exePath ); + + lua_State *L = state->luaState; + lua_pushcfunction( L, luaTraceback ); + int tracebackidx = lua_gettop( L ); + + luaL_loadfile( L, exePath ); + + if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) { + TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) ); + return false; + } } else { printVersion(); -- cgit v1.2.3