From f5b0fff5a990004375ad43aa6e6c4a11a8b6eb7e Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Sun, 7 Jun 2020 14:34:09 +0200 Subject: [PATCH] Fix debug.debug() for non-string errors. --- src/lib_debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib_debug.c b/src/lib_debug.c index a485ff8e..07262830 100644 --- a/src/lib_debug.c +++ b/src/lib_debug.c @@ -369,7 +369,8 @@ LJLIB_CF(debug_debug) return 0; if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || lua_pcall(L, 0, 0, 0)) { - fputs(lua_tostring(L, -1), stderr); + const char *s = lua_tostring(L, -1); + fputs(s ? s : "(error object is not a string)", stderr); fputs("\n", stderr); } lua_settop(L, 0); /* remove eventual returns */