lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, 27 Nov 2012, Roberto Ierusalimschy wrote:

> > That is correct, but because luaL_error() does not actually return, the
> > calling function of luaL_verror() will never be returned to, and thus the
> > va_end() that is there will never be called..
>
> Who calls va_start and its corresponding va_end is lua_pushvfstring
> (actually luaO_pushfstring, an internal function), which usually
> returns. The error is raised after the call to va_end.  Nobody else
> needs to call either va_start or va_end.

yes they do, because lua0_pushfstring() is not in the call path here. your
example was

LUA_API int luaL_verror (lua_State *L, const char *fmt, va_list argp) {
  return luaL_error(L, "%s", lua_pushvfstring(L, fmt, argp));
}

so any caller of luaL_verror() would need to provide a valid va_list, and
the only way to get this is to use va_start() before the luaL_verror()
call and va_end() after.. but you cannot do that, since that code will not
be reached.

regards,
iain