[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bug in lua_getfield() ?
- From: Petr Stetiar <ynezz@...>
- Date: Mon, 26 Mar 2007 09:49:27 +0200
Rici Lake <lua@ricilake.net> [2007-03-25 23:36:16]:
> Petr Stetiar wrote:
> >The problem happens in my C lua_get_function(), which calls lua_getfield()
> >about 200 times per minute.
> >
> >int lua_get_function(char *function)
> >{
> > ... snip ...
> > lua_getfield(L, LUA_GLOBALSINDEX, function);
> > ... snip ...
> >}
>
> Do you check to make sure that there was a hook with that name? It's
> hard to tell from your snipped code.
>
> You should be doing something like:
>
> lua_getfield(L, LUA_GLOBALSINDEX, function);
> if (!lua_isnil(L, -1)) { ... call the function ... }
Ok, but the memory is already corrupted by lua_getfield(), even before check
lua_isnil().
-- ynezz