Tricky _PROMPT may trigger undefined behavior in lua.c
This commit is contained in:
5
lua.c
5
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
|
** 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
|
** message on the top of the stack.
|
||||||
** is a string, as it was either generated by Lua or by 'msghandler'.
|
|
||||||
*/
|
*/
|
||||||
static int report (lua_State *L, int status) {
|
static int report (lua_State *L, int status) {
|
||||||
if (status != LUA_OK) {
|
if (status != LUA_OK) {
|
||||||
const char *msg = lua_tostring(L, -1);
|
const char *msg = lua_tostring(L, -1);
|
||||||
|
if (msg == NULL)
|
||||||
|
msg = "(error message not a string)";
|
||||||
l_message(progname, msg);
|
l_message(progname, msg);
|
||||||
lua_pop(L, 1); /* remove message */
|
lua_pop(L, 1); /* remove message */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user