[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_rawgeti segfault
- From: Peter Cawley <lua@...>
- Date: Sat, 12 Nov 2011 13:01:46 +0000
On Sat, Nov 12, 2011 at 12:27 PM, Patrick Rapin <email@example.com> wrote:
>> Reporting inconsistency lua_rawgeti() vs lua_getfield() when [t] is light userdata.
>> Also lua_rawseti().
> According to me, this is irrelevant since in both cases the behavior
> is *undefined* when there is no table at the specified index.
I agree with Patrick's assessment, but I can offer some extra bits:
The lua_raw[gs]eti (and lua_next) functions only have a meaning for
tables, and thus assume that they have been given a table. On the
other hand, lua_getfield has a meaning for all types (as long as they
are tables, or have a metatable), and thus checks the type of what it
has been given, and acts accordingly.
If you want to catch this, then compile with LUA_USE_APICHECK enabled.
Otherwise, like several other places in the C API, it is assumed that
you know what you're doing.