aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-06-05 13:37:16 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-06-05 13:37:16 -0300
commit21ff8de33a5aca9c3c907592b894e4b9ab036d3e (patch)
treeaa547632aa4e833d7c639ccb6baa3d8333505351
parent7eb1ed21b7057ab5f1b921f8271eddcf13659737 (diff)
downloadlua-21ff8de33a5aca9c3c907592b894e4b9ab036d3e.tar.gz
lua-21ff8de33a5aca9c3c907592b894e4b9ab036d3e.tar.bz2
lua-21ff8de33a5aca9c3c907592b894e4b9ab036d3e.zip
Bug: Tricky _PROMPT may trigger undefined behavior
-rw-r--r--lua.c5
1 files 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) {
115 115
116/* 116/*
117** Check whether 'status' is not OK and, if so, prints the error 117** Check whether 'status' is not OK and, if so, prints the error
118** message on the top of the stack. It assumes that the error object 118** message on the top of the stack.
119** is a string, as it was either generated by Lua or by 'msghandler'.
120*/ 119*/
121static int report (lua_State *L, int status) { 120static int report (lua_State *L, int status) {
122 if (status != LUA_OK) { 121 if (status != LUA_OK) {
123 const char *msg = lua_tostring(L, -1); 122 const char *msg = lua_tostring(L, -1);
123 if (msg == NULL)
124 msg = "(error message not a string)";
124 l_message(progname, msg); 125 l_message(progname, msg);
125 lua_pop(L, 1); /* remove message */ 126 lua_pop(L, 1); /* remove message */
126 } 127 }