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

6
lapi.c
View File

@@ -593,12 +593,8 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
const char *ret;
va_list argp;
lua_lock(L);
va_start(argp, fmt);
ret = luaO_pushvfstring(L, fmt, argp);
va_end(argp);
pushvfstring(L, argp, fmt, ret);
luaC_checkGC(L);
if (ret == NULL) /* error? */
luaD_throw(L, LUA_ERRMEM);
lua_unlock(L);
return ret;
}