aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 8d23bc7d..f48060ed 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1043,9 +1043,14 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
1043} 1043}
1044 1044
1045 1045
1046/*
1047** Standard panic funcion just prints an error message. The test
1048** with 'lua_type' avoids possible memory errors in 'lua_tostring'.
1049*/
1046static int panic (lua_State *L) { 1050static int panic (lua_State *L) {
1047 const char *msg = lua_tostring(L, -1); 1051 const char *msg = (lua_type(L, -1) == LUA_TSTRING)
1048 if (msg == NULL) msg = "error object is not a string"; 1052 ? lua_tostring(L, -1)
1053 : "error object is not a string";
1049 lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n", 1054 lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n",
1050 msg); 1055 msg);
1051 return 0; /* return to Lua to abort */ 1056 return 0; /* return to Lua to abort */