mirror of https://github.com/rusefi/lua.git
out-of-bound upvalues (in C) are acceptable indices
This commit is contained in:
parent
fa4b4c1100
commit
c9ea94ec92
15
lapi.c
15
lapi.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 1.231 2003/02/24 16:54:20 roberto Exp roberto $
|
** $Id: lapi.c,v 1.232 2003/02/27 12:33:07 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -56,8 +56,10 @@ static TObject *negindex (lua_State *L, int idx) {
|
||||||
default: {
|
default: {
|
||||||
TObject *func = (L->base - 1);
|
TObject *func = (L->base - 1);
|
||||||
idx = LUA_GLOBALSINDEX - idx;
|
idx = LUA_GLOBALSINDEX - idx;
|
||||||
api_check(L, iscfunction(func) && idx <= clvalue(func)->c.nupvalues);
|
lua_assert(iscfunction(func));
|
||||||
return &clvalue(func)->c.upvalue[idx-1];
|
return (idx <= clvalue(func)->c.nupvalues)
|
||||||
|
? &clvalue(func)->c.upvalue[idx-1]
|
||||||
|
: NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,8 +70,11 @@ static TObject *luaA_index (lua_State *L, int idx) {
|
||||||
api_check(L, idx <= L->top - L->base);
|
api_check(L, idx <= L->top - L->base);
|
||||||
return L->base + idx - 1;
|
return L->base + idx - 1;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
return negindex(L, idx);
|
TObject *o = negindex(L, idx);
|
||||||
|
api_check(L, o != NULL);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue