From aaf35336533c17cbeb9ac8137d13cd7908a13327 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 12 Jun 2024 16:04:25 -0300 Subject: Tricky _PROMPT may trigger undefined behavior in lua.c --- lua.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lua.c') diff --git a/lua.c b/lua.c index 9d347d75..d109acbf 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