diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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 | */ | ||
1046 | static int panic (lua_State *L) { | 1050 | static 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 */ |