diff options
-rw-r--r-- | lauxlib.c | 4 | ||||
-rw-r--r-- | ldblib.c | 2 | ||||
-rw-r--r-- | ltests.c | 4 |
3 files changed, 7 insertions, 3 deletions
@@ -995,8 +995,10 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { | |||
995 | 995 | ||
996 | 996 | ||
997 | static int panic (lua_State *L) { | 997 | static int panic (lua_State *L) { |
998 | const char *msg = lua_tostring(L, -1); | ||
999 | if (msg == NULL) msg = "error object is not a string"; | ||
998 | lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n", | 1000 | lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n", |
999 | lua_tostring(L, -1)); | 1001 | msg); |
1000 | return 0; /* return to Lua to abort */ | 1002 | return 0; /* return to Lua to abort */ |
1001 | } | 1003 | } |
1002 | 1004 | ||
@@ -417,7 +417,7 @@ static int db_debug (lua_State *L) { | |||
417 | return 0; | 417 | return 0; |
418 | if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || | 418 | if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || |
419 | lua_pcall(L, 0, 0, 0)) | 419 | lua_pcall(L, 0, 0, 0)) |
420 | lua_writestringerror("%s\n", lua_tostring(L, -1)); | 420 | lua_writestringerror("%s\n", luaL_tolstring(L, -1, NULL)); |
421 | lua_settop(L, 0); /* remove eventual returns */ | 421 | lua_settop(L, 0); /* remove eventual returns */ |
422 | } | 422 | } |
423 | } | 423 | } |
@@ -73,8 +73,10 @@ static void badexit (const char *fmt, const char *s1, const char *s2) { | |||
73 | 73 | ||
74 | 74 | ||
75 | static int tpanic (lua_State *L) { | 75 | static int tpanic (lua_State *L) { |
76 | const char *msg = lua_tostring(L, -1); | ||
77 | if (msg == NULL) msg = "error object is not a string"; | ||
76 | return (badexit("PANIC: unprotected error in call to Lua API (%s)\n", | 78 | return (badexit("PANIC: unprotected error in call to Lua API (%s)\n", |
77 | lua_tostring(L, -1), NULL), | 79 | msg, NULL), |
78 | 0); /* do not return to Lua */ | 80 | 0); /* do not return to Lua */ |
79 | } | 81 | } |
80 | 82 | ||