lua

A copy of the Lua development repository
Log | Files | Refs | README

commit aaf35336533c17cbeb9ac8137d13cd7908a13327
parent b529aefc531276775f8827052d5594749232cf07
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Wed, 12 Jun 2024 16:03:58 -0300

Tricky _PROMPT may trigger undefined behavior in lua.c

Diffstat:
Mlua.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 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 */ }