diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-05 13:37:16 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-05 13:37:16 -0300 |
commit | 21ff8de33a5aca9c3c907592b894e4b9ab036d3e (patch) | |
tree | aa547632aa4e833d7c639ccb6baa3d8333505351 | |
parent | 7eb1ed21b7057ab5f1b921f8271eddcf13659737 (diff) | |
download | lua-21ff8de33a5aca9c3c907592b894e4b9ab036d3e.tar.gz lua-21ff8de33a5aca9c3c907592b894e4b9ab036d3e.tar.bz2 lua-21ff8de33a5aca9c3c907592b894e4b9ab036d3e.zip |
Bug: Tricky _PROMPT may trigger undefined behavior
-rw-r--r-- | lua.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 | */ |
121 | static int report (lua_State *L, int status) { | 120 | static 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 | } |