From 21ff8de33a5aca9c3c907592b894e4b9ab036d3e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 5 Jun 2024 13:37:16 -0300 Subject: Bug: Tricky _PROMPT may trigger undefined behavior --- lua.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua.c b/lua.c index af1f6a3e..6da331f1 100644 --- a/lua.c +++ b/lua.c @@ -115,12 +115,13 @@ static void l_message (const char *pname, const char *msg) { /* ** Check whether 'status' is not OK and, if so, prints the error -** message on the top of the stack. It assumes that the error object -** is a string, as it was either generated by Lua or by 'msghandler'. +** message on the top of the stack. */ static int report (lua_State *L, int status) { if (status != LUA_OK) { const char *msg = lua_tostring(L, -1); + if (msg == NULL) + msg = "(error message not a string)"; l_message(progname, msg); lua_pop(L, 1); /* remove message */ } -- cgit v1.2.3-55-g6feb