From fe8c365281f0f23f24ea79357296b8b9c91b7fdb Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 13 Aug 2004 16:52:53 -0300 Subject: [PATCH] =?UTF-8?q?default=20state=20(created=20by=20`luaL=5Fnewst?= =?UTF-8?q?ate=C2=B4)=20has=20a=20default=20panic=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lauxlib.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lauxlib.c b/lauxlib.c index ae18348c..83bae2e4 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.120 2004/07/09 18:23:17 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.121 2004/07/13 20:11:32 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -656,7 +656,15 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { } -LUALIB_API lua_State *luaL_newstate (void) { - return lua_newstate(l_alloc, NULL); +static int panic (lua_State *L) { + fprintf(stderr, "PANIC: unprotected error during Lua-API call\n"); + return 0; +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + lua_atpanic(L, &panic); + return L; }