diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-12 16:04:25 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-12 16:04:25 -0300 |
| commit | aaf35336533c17cbeb9ac8137d13cd7908a13327 (patch) | |
| tree | 2ad54b93da119c80dacd3a8916d356d947db75c3 | |
| parent | b529aefc531276775f8827052d5594749232cf07 (diff) | |
| download | lua-aaf35336533c17cbeb9ac8137d13cd7908a13327.tar.gz lua-aaf35336533c17cbeb9ac8137d13cd7908a13327.tar.bz2 lua-aaf35336533c17cbeb9ac8137d13cd7908a13327.zip | |
Tricky _PROMPT may trigger undefined behavior in lua.c
| -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 | } |
