[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: semantics of luaM_growvector?
- From: Paul Du Bois <paul.dubois@...>
- Date: Wed, 12 Jan 2005 11:53:37 -0800
On Wed, 12 Jan 2005 10:42:14 -0200, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
> > In 4.0.1, this call allows kproto to grow until it has MAXARG_A-1
> > elements.
>
> Are you sure about that?
Hi Roberto, thanks for the reply. Sorry, I should have posted code
snippets as well. Here they are:
#define luaM_growvector(L, v,nelems,inc,t,e,l) \
((v)=(t *)luaM_growaux(L, v,nelems,inc,sizeof(t),e,l))
void *luaM_growaux (lua_State *L, void *block, size_t nelems,
int inc, size_t size, const char *errormsg, size_t limit) {
size_t newn = nelems+inc;
if (nelems >= limit-inc) lua_error(L, errormsg);
If one ignores int-overflow problems, the test can be written
if (nelems+inc >= limit) lua_error(...);
And the problem is more obvious.
paul