New macro 'pushvfstring'

Helps to ensure that 'luaO_pushvfstring' is being called correctly,
with an error check after closing the vararg list with 'va_end'.
This commit is contained in:
Roberto Ierusalimschy
2025-04-23 11:55:04 -03:00
parent 9b014d4bcd
commit e055905914
4 changed files with 13 additions and 16 deletions

View File

@@ -852,12 +852,8 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
const char *msg;
va_list argp;
luaC_checkGC(L); /* error message uses memory */
va_start(argp, fmt);
msg = luaO_pushvfstring(L, fmt, argp); /* format message */
va_end(argp);
if (msg == NULL) /* no memory to format message? */
luaD_throw(L, LUA_ERRMEM);
else if (isLua(ci)) { /* Lua function? */
pushvfstring(L, argp, fmt, msg);
if (isLua(ci)) { /* Lua function? */
/* add source:line information */
luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));
setobjs2s(L, L->top.p - 2, L->top.p - 1); /* remove 'msg' */