lua-users home
lua-l archive

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

On 31 August 2011 14:56, liam mail <> wrote:
> On 31 August 2011 14:21, Luiz Henrique de Figueiredo
> <> wrote:
>>> But how do you validate, say, an index you give to a C function that
>>> queries the Lua stack?
>> Use lua_type. The manual says that it returns LUA_TNONE for a non-valid index.
> Only a non valid acceptable index, a non valid non acceptable index is
> undefined and there is no way to determine if an index is non valid
> non acceptable.
> Liam

What I should really say is an non acceptable index which is greater
than the stackspace plus extra space plus 1 (end of an array can be
used to compare an index inside the array) is undefined, this is due
to index2adr if I understand correctly. For example using index 30
when stackspace is 20 and extraspace is 5* then the following is UB in
if (o >= L->top)

* numbers pulled out of the air.