[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: illegal luaL_buffer usage in loadlib.c
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 13 Dec 2017 10:48:02 -0200
> > In findloader (https://www.lua.org/source/5.3/loadlib.c.html#findloader)
> > luaL_buffinit is called before pushing the searchers table onto the
> > stack.
> > This breaks the "balanced stack" that luaL_buffinit is documented to expect.
> > Also, later code then assumes that the searchers table is at index 3.
> > Now, this doesn't actually manifest in a bug in PUC Rio lua 5.3, as
> > the implementation of luaL_buffinit doesn't touch the stack.
> > However if someone were to extract parts of loadlib.c to use with a
> > different auxlib implementation then there might be issues.
> > The fix is to simply move the luaL_buffinit call below the lua_getfield call.
> Thanks for the correction.
BTW, 'searchpath' has the same issue. (The call to 'luaL_gsub' leaves
a string on the stack.)