'luaD_seterrorobj' should not raise errors

This function can be called unprotected, so it should not raise any
kind of errors. (It could raise a memory-allocation error when creating
a message).
This commit is contained in:
Roberto Ierusalimschy
2025-03-12 15:51:16 -03:00
parent d9e0f64a5d
commit c931d86e98
5 changed files with 25 additions and 22 deletions

View File

@@ -832,6 +832,10 @@ l_noret luaG_errormsg (lua_State *L) {
L->top.p++; /* assume EXTRA_STACK */
luaD_callnoyield(L, L->top.p - 2, 1); /* call it */
}
if (ttisnil(s2v(L->top.p - 1))) { /* error object is nil? */
/* change it to a proper message */
setsvalue2s(L, L->top.p - 1, luaS_newliteral(L, "<no error object>"));
}
luaD_throw(L, LUA_ERRRUN);
}